【问题标题】:Redux toolkit createApi search by api query dataRedux 工具包 createApi 通过 api 查询数据搜索
【发布时间】:2022-08-09 13:19:01
【问题描述】:

我正在使用 redux-toolkit RTK,我很喜欢它。但我有一个问题。

基本上,我正在调用一个返回数据的 URL,然后我想渲染各种子元素。让我解释得更好。

我的主屏幕有一个参数pathname,我用它来调用const { data, isLoading, isError, error } = useGetArticleQuery(route.params?.pathname);

但后来我想使用这样的组件<News id={data.id} />

问题是:如何执行选择器之类的操作来按 id 查找文章查询结果?

非常感谢!

    标签: reactjs react-native redux react-redux redux-toolkit


    【解决方案1】:

    我已经使用 Redux-toolkit 在 api 中实现了分页,你可以传递 url。

    https://codesandbox.io/s/make-global-api-using-redux-toolkit-09hdc9

    【讨论】:

      猜你喜欢
      • 2022-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 1970-01-01
      • 2022-11-18
      • 2022-01-21
      • 1970-01-01
      相关资源
      最近更新 更多