Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/451.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
Javascript React Native:TypeError:(0,_Native.useTheme)不是函数。(在';(0,#native.useTheme)(';,';(0,#native.useTheme)';中未定义)_Javascript_React Native_React Navigation - Fatal编程技术网

Javascript React Native:TypeError:(0,_Native.useTheme)不是函数。(在';(0,#native.useTheme)(';,';(0,#native.useTheme)';中未定义)

Javascript React Native:TypeError:(0,_Native.useTheme)不是函数。(在';(0,#native.useTheme)(';,';(0,#native.useTheme)';中未定义),javascript,react-native,react-navigation,Javascript,React Native,React Navigation,我面临一个关于上述错误的问题。仔细研究这个问题之后,我找到了提示错误的代码块 注意:我使用的是react导航版本4.4.4 此错误位于: in HeaderButton (at HeaderButton.js:9) in CustomHeaderButton (at HeaderItems.js:38) in Item (at PlacesListScreen.js:22) 相应的代码块是 PlacesListScreen.navigationOptions = (navData) =>

我面临一个关于上述错误的问题。仔细研究这个问题之后,我找到了提示错误的代码块

注意:我使用的是react导航版本4.4.4

此错误位于:

in HeaderButton (at HeaderButton.js:9)
in CustomHeaderButton (at HeaderItems.js:38)
in Item (at PlacesListScreen.js:22)
相应的代码块是

 PlacesListScreen.navigationOptions = (navData) => {
  return {
    headerTitle: 'Places',
    headerTitleStyle: {
      // flex: 1,
      textAlign: 'center',
    },
    headerRight: () => {
      return (
        <HeaderButtons HeaderButtonComponent={HeaderBtn}>
          <Item
            title='Add Place'
            iconName={Platform.OS === 'android' ? 'add' : 'ios-add'}
            onPress={() => {
              navData.navigation.navigate('NewPlace')
            }}
          />
        </HeaderButtons>
      )
    },
  }
}
PlacesListScreen.navigationOptions=(navData)=>{
返回{
标题:“地点”,
头饰样式:{
//弹性:1,
textAlign:'中心',
},
头灯:()=>{
返回(
{
navData.navigation.navigate('NewPlace')
}}
/>
)
},
}
}
现在,错误行指向道具,但我不知道这有什么问题

帮助信息:我已导入以下文件

从“反应导航标题按钮”导入{HeaderButtons,Item}

从“../components/HeaderButton”导入HeaderBtn

而HeaderBtn具有以下代码:

import React from 'react'
import { HeaderButton } from 'react-navigation-header-buttons'
import { Ionicons } from '@expo/vector-icons'
import { Platform } from 'react-native'
import Colors from '../constants/Colors'

const CustomHeaderButton = (props) => {
  return (
    <HeaderButton
      {...props}
      IconComponent={Ionicons}
      iconSize={23}
      color={Platform.OS === 'android' ? Colors.accent : Colors.primary}
    />
  )
}
export default CustomHeaderButton
从“React”导入React
从“反应导航标题按钮”导入{HeaderButton}
从“@expo/vector icons”导入{Ionicons}
从“react native”导入{Platform}
从“../constants/Colors”导入颜色
const CustomHeaderButton=(道具)=>{
返回(
)
}
导出默认CustomHeaderButton

该库的最新版本适用于React Navigation 5。您似乎正在使用旧版本的React导航。