来自 React Navigation 的 StackNavigator 中的 header 样式错误
Error with the header styling in StackNavigator from React Navigation
我正在使用 React Navigation
中的 StackNavigator
,我想为 Android 平台添加 header 样式,但是在添加额外的样式后出现错误:
Objects are not valid as a React child (found: object with keys
{style}).If you meant to render a collection of children, use an array
instead.
这是我的代码:
static navigationOptions ={
header: {
style: {
marginTop: Platform.OS === 'android' ? 24 : 0
}
}
}
如何解决这个问题?
您使用的方法已弃用。
您可以使用以下代码,
static navigationOptions = {
headerStyle: { marginTop: Platform.OS === 'android' ? 24 : 0 }
}
我正在使用 React Navigation
中的 StackNavigator
,我想为 Android 平台添加 header 样式,但是在添加额外的样式后出现错误:
Objects are not valid as a React child (found: object with keys {style}).If you meant to render a collection of children, use an array instead.
这是我的代码:
static navigationOptions ={
header: {
style: {
marginTop: Platform.OS === 'android' ? 24 : 0
}
}
}
如何解决这个问题?
您使用的方法已弃用。
您可以使用以下代码,
static navigationOptions = {
headerStyle: { marginTop: Platform.OS === 'android' ? 24 : 0 }
}