从子路由提交的父路由上的Action Loader函数重定向回到父路由
因此,我正在努力努力,我敢肯定,我缺少一个优雅的解决方案。我有一个嵌套的路由系统,其中父/data/creams
(绿色)的项目列表在其上有操作表格以及操作加载程序的位置。但是,这些可以从子路由/data/data/$ streamId
(紫色)提交。所有操作都可以正常工作,除非用户在儿童路线上,否则将其重定向回父母。我可以用重定向
来解决此问题,并将当前位置嵌入小暂停表单中,但是当呼叫失败时,我无法使用useactiondata
显示错误通知。
So I am struggling with something that I am sure has an elegant solution that I am missing. I have a nested route system where the parent /data/streams
(green) has a list of items that have action forms on them and where the action loader is located. However, these can be submitted from a child route /data/streams/$streamId
(purple). All works fine except if the user is on a child route they are redirected back to the parent. I can kind of solve this with redirect
and embedding the current location in the small pause form, but then I can't use useActionData
for displaying error notifications when a call fails.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
混音将
< form>
提交为导航(标准浏览器功能)。这就是为什么您的子路由帖子正在导航到父路线的原因(因为您要发布到的地方)。混音还支持不是导航(标准获取)的表单。为此,请使用
< fetcher.form>
。注意:从操作返回的数据可在fetcher.data
上获得。还要检查fetcher.state
和fetcher.submission
以处理乐观的UI。https://remix.run/docs/docs/docs/en/en/en/v1/api/api/remix## Usefetcher
Remix treats
<Form>
submissions as navigations (standard browser feature). That is why your child route POST is navigating to the parent route (since that's where you're posting to).Remix also supports form submissions that are not navigations (standard fetch). To do this, use
<fetcher.Form>
. NOTE: data returned from the action is available onfetcher.data
. Also checkfetcher.state
andfetcher.submission
to handle optimistic UI.https://remix.run/docs/en/v1/api/remix#usefetcher