0

我偶然发现了以下问题(从标题中的按钮导航到不同的屏幕)中发现的相同问题,该问题在Githb上重复。与这些功能相关的文档可在此处此处找到。

我尝试实施建议的解决方案,但出现以下错误

Objects are not valid as React child (found: object with keys{right}). If you meant to render a collection of children, use an array instead.

如果您能帮助我,将不胜感激。

有问题的组件:

class Bookings extends Component {
   state = {
     BookingsList: [],
    }
    static navigationOptions = {
      title: 'Bookings',
      headerStyle: {
       backgroundColor: '#49E841'
     },
     header:({ navigate }) => ({
       Right: (
        <HomeButton navigate={navigate}/>
        ),
      }),
    }
  //...More stuff that's not relevant
 }

 class HomeButton extends Component {
   render() {
   console.log(this.props)
   return (
   <TouchableHighlight
     onPress={() => this.props.navigate('Home')}
   >
     <View>
       <Image
          source={require('./Assets/home.png')}
       />
    </View>
  </TouchableHighlight>
  )}
 };

 const RallyMobileNavigator = StackNavigator({
   Home: { screen: RallyMobile },
   LogIn: { screen: LogIn },
   Bookings: { screen: Bookings},
   Menu: { screen: Menu },
   },{
    initialRouteName: 'Home',
    headerMode: 'screen'
  });

这是堆栈跟踪:

堆栈跟踪

4

0 回答 0