【问题标题】: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;
}