How to access record's internals in Show/Edit/

2019-08-10 22:37发布

Similar to admin-on-rest: Access row's column data within a Datagrid component although I think it doesn't apply to my cases:

 export const PlantShow = (props) => {
 return (<Show {...props}>
      <TabbedShowLayout>
        <Tab label="Analytics">
            { record.oneId && <MetricsCharts {...props} manufacturer="one" /> }
            { record.otherId && <MetricsCharts {...props} manufacturer="other" /> }
            { record.anotherId && <MetricsCharts {...props} manufacturer="another" /> }
        </Tab>
    </TabbedShowLayout>
 </Show>)
}

There should be a way to access current record's internals so I can introduce conditional logic .. I didn't find anything useful in props.. I even tried to inject {record} in PlantShow function but that didn't work either. Also DependentInput definitely doesn't help here

Thanks!

1条回答
萌系小妹纸
2楼-- · 2019-08-10 22:53

You'll have to use an intermediate component as a child of Show. It will receive the record prop.

See https://codesandbox.io/s/wyln51r907 (in posts.js, around the PostShow component.

查看更多
登录 后发表回答