我正在尝试使用react-admin创建扩展选项。
在我的AdminPanel.js
中:
class AdminPanel extends React.Component {
render() {
return (
<div>
<Admin dataProvider={myDataProvider}>
...
<Resource title="Submission" name="submission" list={SubmissionList} />
...
</Admin>
</div>
);
}
}
const SubmissionList = (props) => (
<List {...props} pagination={<PostPagination />}>
<Datagrid expand={<ContentShow/>}>
...
</Datagrid>
</List>
);
const ContentShow = props => (
<Show
{...props}
title=" "
>
<SimpleShowLayout>
<RichTextField source="content" />
</SimpleShowLayout>
</Show>
);
问题是当我尝试扩展条目时,它给我说Unknown dataProvider函数:getOne的错误。
我该如何解决?
最好不再使用dataProvider
不使用SimpleShowLayout
而直接使用Show
const ContentShow = props => (
<SimpleShowLayout>
<RichTextField source="content" />
</SimpleShowLayout>
);
ContentShow
是否作为Resource
道具传递给show
组件?如果不是,则ContentShow
组件没有actions
道具。因此找不到函数getOne
。 (参考:https://github.com/marmelab/react-admin/blob/53aac9b84760cf56fa3d5bf5a05cea48245e3c92/packages/ra-core/src/controller/useShowController.ts#L57)
您应该传递一个依赖于录制道具的演示组件(在这种情况下为content
对象。