从stacknavigator传递数组作为道具来响应本地导航?

时间:2020-04-21 11:32:48

标签: reactjs react-native state react-navigation prop

  state = {
    title: []
  }
  render() {
    return (<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="Dashboard"
component={Dashboard}
initialParams={{title:this.state.title}}
/>
</Stack.Navigator>
      </NavigationContainer>}
export default class Dashboard extends React.Component {
    constructor(prop) {
        super(prop);
        console.log(  this.props.route.params)
        this.state = {
            search:"",
templist:this.props.route.params.title,
            title: this.props.route.params.title}

**我想将标题(Array)传递给Screen 但是我没有在屏幕上显示数组**

1 个答案:

答案 0 :(得分:0)

偶然发现了类似的问题。通过对我试图传递的数组进行字符串化使其工作

{title: JSON.stringify(this.state.title)}