Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/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 反应导航头灯不可见_React Native_React Navigation_React Navigation Stack - Fatal编程技术网

React native 反应导航头灯不可见

React native 反应导航头灯不可见,react-native,react-navigation,react-navigation-stack,React Native,React Navigation,React Navigation Stack,我正在尝试渲染屏幕标题右侧的按钮。但是我没有得到想要的结果。我已向一名官员介绍了情况。这是我的屏幕的最新版本。 这是我的导航代码段 <NavigationContainer> <Stack.Navigator screenOptions={{ headerStyle: { backgroundColor: Colors.header.backgroundColor,

我正在尝试渲染屏幕标题右侧的按钮。但是我没有得到想要的结果。我已向一名官员介绍了情况。这是我的屏幕的最新版本。
这是我的导航代码段

 <NavigationContainer>
            <Stack.Navigator screenOptions={{
                headerStyle: {
                    backgroundColor: Colors.header.backgroundColor,
                },
                headerTintColor: Colors.header.fontColor,
                headerTitleAlign: 'left',
                headerTitleStyle: {
                    fontSize: Fonts.size.regular
                }
            }}>
                <Stack.Screen name='Home' component={Home} options={{
                    headerTitle: 'Seguro',
                    headerRight: () => {
                        <Button              // I want to render this button
                            onPress={() => console.log('This is a button!')}
                            title="Info"
                            color="#fff"
                        />
                    }
                }} />
                <Stack.Screen name='Login' component={Login} />
            </Stack.Navigator>
        </NavigationContainer>

{
console.log('这是一个按钮!')}
title=“Info”
color=“#fff”
/>
}
}} />

问题是您没有返回任何内容

选项1:隐式返回..括在括号中表示隐式返回

<Stack.Screen name='Home' 
     component={Home} 
     options={{
                    headerTitle: 'Seguro',
                    headerRight: () => (
                        <Button             
                            onPress={() => console.log('This is a button!')}
                            title="Info"
                            color="#fff"
                        />
                    )
            }} />
<Stack.Screen name='Home' 
     component={Home} 
     options={{
                    headerTitle: 'Seguro',
                    headerRight: () => { 
                       return (
                        <Button             
                            onPress={() => console.log('This is a button!')}
                            title="Info"
                            color="#fff"
                        />
                    )
              }
            }} />
(
console.log('这是一个按钮!')}
title=“Info”
color=“#fff”
/>
)
}} />
选项2:显式返回

<Stack.Screen name='Home' 
     component={Home} 
     options={{
                    headerTitle: 'Seguro',
                    headerRight: () => (
                        <Button             
                            onPress={() => console.log('This is a button!')}
                            title="Info"
                            color="#fff"
                        />
                    )
            }} />
<Stack.Screen name='Home' 
     component={Home} 
     options={{
                    headerTitle: 'Seguro',
                    headerRight: () => { 
                       return (
                        <Button             
                            onPress={() => console.log('This is a button!')}
                            title="Info"
                            color="#fff"
                        />
                    )
              }
            }} />
{
返回(
console.log('这是一个按钮!')}
title=“Info”
color=“#fff”
/>
)
}
}} />

该死!你救了我一天。我怎么会错过这件事