【问题标题】:react-native-navigation and reduxreact-native-navigation 和 redux
【发布时间】:2020-05-18 05:19:16
【问题描述】:

如何使用 react-native-navigation 编写 redux 数据流? 这是我的代码:

- Navigation.registerComponent('Scan', () => props => (   <Provider
  store={store}>
      <ScanScreen {...props} />   </Provider> ))

【问题讨论】:

标签: redux react-redux react-native-navigation


【解决方案1】:

您需要使用 react-native-navigation 中的 registerComponentWithRedux 而不是 registerComponent

而且您不需要在 Provider 中手动包装您的组件。

请参考下面的sn-p进行集成:

Navigation.registerComponentWithRedux(
    "your_route_name",
    () => YourScreenComponent,
    Provider,
    store
);

在上面的代码sn-p中:

  1. 你会得到 Provider from : import { Provider } from 'react-redux';
  2. store 使用 redux configureStore 配置 方法

【讨论】:

    猜你喜欢
    • 2018-05-23
    • 2017-11-28
    • 2019-10-22
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    • 1970-01-01
    • 2022-10-25
    • 2019-06-25
    相关资源
    最近更新 更多