【问题标题】:How to pass redux props and navigation parameters together?如何同时传递 redux 的 props 和导航参数?
【发布时间】:2021-09-08 13:37:08
【问题描述】:

我已经成功传递了react native导航参数如下:

PageOne = ({ navigation, route }) => {
const { itemId, otherParam } = route.params;
...
}

我已经完成了传递 redux 道具以使用 redux 操作,如下所示:

PageTwo = (props) => {

}

如何将参数和 props 放在一个组件中?

我们将非常感谢您的帮助!

【问题讨论】:

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


    【解决方案1】:

    这应该可以工作

    Page = (props) => {
    const { navigation, route } = props
    const { itemId, otherParam } = route.params;
    ...
    }

    【讨论】:

    • 它的工作就像一个骗子!你为我节省了一天。谢谢。
    【解决方案2】:

    你可以像这样组合它们:

    PageOne = ({ navigation, route, reduxParam1,reduxParam2 }) => {
    const { itemId, otherParam } = route.params;
    }
    

    或者你也可以这样使用

    PageOne = (props) => {
    const { itemId, otherParam } = props.route.params;
    }
    

    【讨论】:

    • 非常感谢您的回答!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-08
    • 1970-01-01
    • 1970-01-01
    • 2019-05-09
    • 1970-01-01
    • 2021-12-29
    • 1970-01-01
    相关资源
    最近更新 更多