【问题标题】:React-Admin: Access record.id inside Show View componentReact-Admin:在 Show View 组件中访问 record.id
【发布时间】:2021-12-29 09:57:04
【问题描述】:

我正在尝试一些看起来很简单的东西,但我不明白,即使经过多次搜索。

我想要做的是将 record.id 作为参数传递给函数,如下所示: (函数为ClientShowGroupSum

export const ClientsShow = props => {
    const classes = useStyles(); 
    const chartDataThisYear = ClientShowGroupSum(null, "other", record.id)

    return (
        <Show actions={<ShowActions />} {...props}>
            <TabbedShowLayout >
                <Tab label="Principal">
                    <SimpleLineChart
                      chartTitle="Faturamento R$"
                      mylabels={ chartDataThisYear.chartlabels } // using data here
                      myvalues={ chartDataThisYear.chartvalues } // using data here                       
                      tooltipXpre={"Data: "}
                      tooltipYpre={"R$"} />
                </Tab>
            </TabbedShowLayout>

【问题讨论】:

    标签: reactjs react-admin


    【解决方案1】:

    props 中有 id

    const chartDataThisYear = ClientShowGroupSum(null, "other", props.id)

    【讨论】:

    • 哇...真的很简单。我正在尝试 record.id 和其他东西 :( 感谢您的快速响应。
    猜你喜欢
    • 1970-01-01
    • 2018-03-06
    • 2020-08-16
    • 1970-01-01
    • 2019-09-09
    • 2020-05-20
    • 2021-03-18
    • 2020-09-08
    • 1970-01-01
    相关资源
    最近更新 更多