在“设置”屏幕中缺少TabBar Review图标

时间:2018-03-10 11:53:34

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

当我在设置屏幕上时,我看到缺少评论图标(收藏夹)。它显示我何时回到Review屏幕。为什么会这样。看我拍的截图。从我的项目中粘贴相关的代码片段以供参考。

enter image description here

 const MainNavigator = TabNavigator({
      map: { screen: MapScreen },
      deck: { screen: DeckScreen },
      review: {
        screen: StackNavigator({
          review: { screen: ReviewScreen },
          settings: { screen: SettingsScreen }
        })
      }
    }, {
      tabBarPosition: 'bottom',
      tabBarOptions: {
        labelStyle: { fontSize: 12 }
      }
    });

class ReviewScreen extends Component {
  static navigationOptions = props => {
    const {navigation} = props;
    const {navigate} = navigation;
    return {
        tabBarIcon: ({ tintColor }) => {
            return <Icon name="favorite" size={30} color={tintColor} />

        },
        headerTitle: 'Review Jobs',
        headerRight: (
            <Button
                title="Settings"
                onPress={() => navigate('settings')}
                backgroundColor="rgba(0,0,0,0)"
                color="rgba(0, 122, 255, 1)"
            />
        )
    }
  }

这里的潜在客户表示赞赏。

1 个答案:

答案 0 :(得分:2)

您的代码存在问题,因为您要将tintColor中的每个图标static navigationOptions设置为

tabBarIcon: ({tintColor}) => {
        return <Icon name="favorite" size={30} color={tintColor}/>

      }

并且Settings Screen没有,Icon也需要TabNavigator,因为它在null内,因此navigationOptions正在那里呈现。

因此,您需要将Settings Screen中的static navigationOptions = props => { const {navigation} = props; const {navigate} = navigation; return { tabBarIcon: ({tintColor}) => { return <Icon name="favorite" size={30} color={tintColor}/> } } } 设置为

App.js

或者您可以将screen: TabNavigator({ map: { screen: MapScreen, navigationOptions: { tabBarIcon: ({ tintColor }) => ( <Icon name="favorite" size={30} color={tintColor}/> ) } }, // ....so on 导航文件中的默认图标添加为

uBit.init();
uBit.serial.baud(115200);

MicroBitI2C i2c = MicroBitI2C(I2C_SDA0, I2C_SCL0); 
MicroBitAccelerometer accelerometer = MicroBitAccelerometer(i2c);




while(1) {

    int x=uBit.accelerometer.getX();
    int y=uBit.accelerometer.getX();
    int z=uBit.accelerometer.getX();

    stringstream result;
    result << x << "," << y << "," << z;
    uBit.serial.send(result.c_str());
    uBit.serial.send("\r\n");
}

希望有所帮助!