useFetchers

useFetchers

返回所有正在运行的获取器的数组。这对于整个应用中未创建抓取器但希望使用其提交来参与乐观 UI 的组件很有用。

¥Returns an array of all in-flight fetchers. This is useful for components throughout the app that didn't create the fetchers but want to use their submissions to participate in an optimistic UI.

import { useFetchers } from "@remix-run/react";

function SomeComponent() {
  const fetchers = useFetchers();
  fetchers[0].formData; // FormData
  fetchers[0].state; // etc.
  // ...
}

fetcher 不包含 fetcher.Formfetcher.submitfetcher.load,只包含 fetcher.formDatafetcher.state 等状态。

¥The fetchers don't contain fetcher.Form, fetcher.submit, or fetcher.load, only the states like fetcher.formData, fetcher.state, etc.

其他资源

¥Additional Resources

讨论

¥Discussions

API

Remix v2.17 中文网 - 粤ICP备13048890号