React-Admin:在 Show View 组件中访问 record.id

React-Admin: Access record.id inside Show View component

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

我想做的是将 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>

您在 props 中有 id

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