问题描述
我正在使用嵌入在另一个 redux 应用程序中的 react-admin,如此处所述 (https://marmelab.com/react-admin/CustomApp.html)
我已经配置了这样的路由
<Route path="/main/posts/:id" render={(routeProps) => <EditGuesser resource="posts" id={decodeURIComponent((routeProps.match).params.id)} basePath={routeProps.match.url} {...routeProps} />} />
<Route path="/main/posts" render={(routeProps) => <ListGuesser hasCreate resource="posts" basePath={routeProps.match.url} {...routeProps} />} />
当用于详细 url 的元素 id 存在于数据库中时,一切正常。
当 id 不存在时,会返回一个错误,然后 react-admin 继续循环调用相同的元素。
这是一个重现问题的代码沙箱:https://codesandbox.io/s/react-admin-embedded-in-another-app-e92hp
我在从详细信息页面删除元素时遇到了类似的问题。这种情况下的解决方案是定义删除后重定向到列表页面。
我认为这需要类似的解决方案,但我不知道在哪里配置重定向到列表页面
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)