Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native “navigationOptions”中的弃用:-“headerLeft:”将在将来的版本中删除。使用“headerLeft:()=>”_React Native - Fatal编程技术网

React native “navigationOptions”中的弃用:-“headerLeft:”将在将来的版本中删除。使用“headerLeft:()=>”

React native “navigationOptions”中的弃用:-“headerLeft:”将在将来的版本中删除。使用“headerLeft:()=>”,react-native,React Native,这是我的代码,当我运行项目时,它会显示一条警告消息: “navigationOptions”中的弃用:-“headerLeft:”将在将来的版本中删除。使用“headerLeft:=>” 有人能告诉我如何解决这个问题吗?只需将headerLeft值包装在函数中即可 HomeScreen.navigationOptions = navData => { return{ headerTitle: 'Title'.toUpperCase(), header

这是我的代码,当我运行项目时,它会显示一条警告消息: “navigationOptions”中的弃用:-“headerLeft:”将在将来的版本中删除。使用“headerLeft:=>”


有人能告诉我如何解决这个问题吗?

只需将headerLeft值包装在函数中即可

HomeScreen.navigationOptions = navData => {
    return{
        headerTitle: 'Title'.toUpperCase(),
        headerLeft: (
            <HeaderButtons HeaderButtonComponent={HeaderButton}>
                <Item title="Menu" iconName="menu" onPress={() => {
                    navData.navigation.toggleDrawer();
                }} />
            </HeaderButtons>
        )
    };
}

只需将headerLeft值包装在函数中即可

HomeScreen.navigationOptions = navData => {
    return{
        headerTitle: 'Title'.toUpperCase(),
        headerLeft: (
            <HeaderButtons HeaderButtonComponent={HeaderButton}>
                <Item title="Menu" iconName="menu" onPress={() => {
                    navData.navigation.toggleDrawer();
                }} />
            </HeaderButtons>
        )
    };
}