代码之家  ›  专栏  ›  技术社区  ›  s-hunter

未定义wix react本机导航注册表组件react

  •  0
  • s-hunter  · 技术社区  · 4 年前

    在react native navigation 7.14中。0 Navigation.registerComponentWithRedux 已被弃用,并建议 并将在下一版本中删除!请 . 有关更多信息,请访问文档 https://wix.github.io/react-native-navigation/api/component#registering-a-component-wrapped-with-providers

    import { Provider } from 'react-redux';
    const store = createStore();
    
    Navigation.registerComponent(`navigation.playground.MyScreen`, () => (props) =>
      <Provider store={store}>
        <MyScreen {...props} />
      </Provider>,
      () => MyScreen)
    );
    

    它和我一起工作很好 注册表组件twithredux 使用不推荐的警告。为了消除警告,我将registerComponentWithRedux更改为以下内容,并在使用启动的应用程序上崩溃

    import { Navigation } from 'react-native-navigation';
    import { Provider } from 'react-redux';
    
    Navigation.registerComponent(ScreenEnum.HOME_SCREEN, () => (props) =>
    <Provider store={store}>
      <HomeScren {...props} />
    </Provider>,
    () => HomeScren);
    

    enter image description here

    1 回复  |  直到 4 年前
        1
  •  1
  •   GʀᴜᴍᴘʏCᴀᴛ    4 年前

    尝试:

    import React from 'react';
    import { Navigation } from 'react-native-navigation';
    import { Provider } from 'react-redux';
    
    Navigation.registerComponent(ScreenEnum.HOME_SCREEN, () => (props) =>
    <Provider store={store}>
      <HomeScreen {...props} />
    </Provider>,
    () => HomeScreen);
    

    在第二个示例中,还要注意 HomeScreen 组件错误销售。

    推荐文章