react-admin expand Unknown dataProvider function:getOne

问题描述 投票:0回答:1

我正在尝试使用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

reactjs react-admin
1个回答
0
投票

不使用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对象。

© www.soinside.com 2019 - 2024. All rights reserved.