简体   繁体   English

NavigatorIOS错误-React Native

[英]NavigatorIOS Error - React Native

React Native 反应本机

When I try to go another page i keep getting this error 当我尝试转到另一页时,我不断收到此错误

goToMenu(){
 this.props.navigator.push({
  component: Menu,
  title: 'Main Menu',
  passProps: {navigator: this.props.navigator},
})
}

<View style={styles.mainContainer}>
 <TouchableHighlight
  style={styles.menuButton}
  onPress={this.goToMenu.bind(this)}>
  <Text style={styles.buttonText}> Go To Menu </Text>
 </TouchableHighlight>
</View>

element type is invalid expected a string (for built-in components) or a class/function for composite components but got object check render method of 'navigatorios' 元素类型无效,预期为字符串(对于内置组件)或复合组件的类/函数,但是对象检查呈现方法为“ navigatorios”

This is a pretty common error. 这是一个非常常见的错误。 It typically means there is an issue with the component you are importing. 通常,这意味着您要导入的组件存在问题。 Check you are exporting Menu and importing it properly (Is the relative filepath correct). 检查您是否正在导出Menu并正确导入它(相对文件路径是否正确)。 If the file path is correct... 如果文件路径正确...

Default export 默认导出

export default () => (
     ...
);

Then import like this 然后像这样导入

import Menu from 'relativeFilePath'

Named export 命名出口

Or if the file Menu is in has multiple named exports eg 或者,如果菜单中的文件具有多个命名的导出,例如

export const Menu ...
export const SomeOtherComponent ...

You will have to deconstruct the import and match the name... 您将必须解构导入并匹配名称...

import {Menu} from 'relativeFilePath' 

See more here ES6+ javascript module export options 在此处查看更多信息ES6 + javascript模块导出选项

If this does not work, the issue is with the Menu component you are trying to navigate to. 如果这不起作用,则问题出在您要导航到的菜单组件上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM