简体   繁体   English

我可以在 remix.run 的 Action 函数中访问 Loader 数据吗?

[英]Can i access Loader data in Action function in remix.run?

Can I access the loader function data in remix inside action Function without passing it from the form or submit function.我可以在不从表单或提交函数中传递它的情况下在动作函数中的 remix 中访问加载器函数数据吗?

something like using useLoaderData inside action Function.类似于在 action Function 中使用 useLoaderData。

No. useLoaderData and useActionData are both hooks used by the UI component once the data is returned from the loader/action.不, useLoaderDatauseActionData都是 UI 组件在从加载器/操作返回数据后使用的钩子。

You will either need to pass the data to the action via FormData, URLSearchParams, or URL params.您将需要通过 FormData、URLSearchParams 或 URL 参数将数据传递给操作。

You can also store data in session or cookies and access it from your action.您还可以将数据存储在会话或 cookie 中,并从您的操作中访问它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM