gpt4 book ai didi

react-native - React Native Navigation with Redux,如何使用?

转载 作者:行者123 更新时间:2023-12-03 23:53:13 26 4
gpt4 key购买 nike

网上有一些关于如何在 Redux 中使用 react-native-navigation 的教程。然而,它们都不是完整的,我真的不明白我需要在我的根函数中返回什么。

如果我真的回来

<Provider store={mystore}>
<MainScreen />
</Provider>

那么,为什么需要使用 registerComponentWithRedux ?
如果我使用 registerComponentWithRedux那么我希望不必再次用提供程序包装我的组件。

任何人都可以澄清这一点,或者是否有人知道一个完整的 react-native-navigation 示例,使用 registerComponentWithRedux ?

如前所述,我在网上看到了很多教程,但它们没有指定应用程序入口文件中返回的内容。

最佳答案

registerComponentWithRedux()已被弃用,取而代之的是 Registering screens with wrapping provider component .

您提供的代码示例实际上是正确的方法,因为 registerComponentWithRedux 函数已被弃用。使用 redux 注册屏幕看起来像这样( sample from RNN docs ):

Navigation.registerComponent('navigation.playground.ReduxScreen', () => (props) => (
<Provider store={reduxStore}>
<ReduxScreen {...props} />
</Provider>
), () => ReduxScreen);

关于react-native - React Native Navigation with Redux,如何使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54274080/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com