在dataProvider react admin中使用dispatch



所以我需要在dataProvider内部调用dispatch来更新上传视频的状态uploadProgress,我已经在中使用了customReducers

//reducers
const uploadProgress = (previousState = 0, { type, payload }) => {
if (type === "ADD_PROGRESS") {
return payload;
}
return previousState;
};
//Admin
<Admin
dataProvider={dataProvider}
dashboard={Dashboard}
loginPage={LoginPage}
authProvider={authProvider}
history={history}
customReducers={{ uploadProgress }}
layout={Layout}
customRoutes={customRoutes}
> .... <Admin />

并且iam使用来自react redux的连接来发送状态作为我的页面组件的道具

const mapStateToProps = (state) => ({ uploadProgress: state.uploadProgress });
export default connect(mapStateToProps)(ContentItemEdit);

当更新或创建video_content时,我会更新uploadProgress状态,运行上传处理到存储,这将显示它的进度条,我会被dataProvider阻止,因为dataProvider必须导出为对象,无法应用连接来调用我的调度,我找不到从react admin 使用连接或调用存储的方法

const dataProvider = {
getList:    (resource, params) => Promise,
getOne:     (resource, params) => Promise,
getMany:    (resource, params) => Promise,
getManyReference: (resource, params) => Promise,
create:     (resource, params) => Promise,
update:     (resource, params) => Promise,
updateMany: (resource, params) => Promise,
delete:     (resource, params) => Promise,
deleteMany: (resource, params) => Promise,
}

"react admin":"3.8.3";,

不能在dataProvider中调用dispatchconnect,因为它不知道React。这是react admin的当前限制。

相关内容

  • 没有找到相关文章

最新更新