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

孤街醉人 提交于 2020-01-05 12:57:11

问题


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:


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.



来源:https://stackoverflow.com/questions/46809402/how-to-access-records-internals-in-show-edit-create

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!