I'm having some trouble working with the NavigatorIOS in react native. If I put my component in the initial route it works just fine but if I try to reach it from another component it gives me this error:
Element type is invalid: expected a string(for built-in components) or a class/function (for composite components) but got: object. check the render method of 'NavigatorIOS'.
here is the code:
import React, { Component, PropTypes } from 'react';
import Dimensions from 'Dimensions';
import {
AppRegistry,
StyleSheet,
Image,
TouchableHighlight,
NavigatorIOS,
FadeInView,
Text,
View
} from 'react-native';
import Menu from './Menu.ios';
class Home extends React.Component {
constructor(props, context) {
super(props, context);
this.onForward = this.onForward.bind(this);
}
onForward(Menu){
this.props.navigator.push({
component: Menu,
title: 'Menu',
navigationBarHidden: true,
});
}
render() {
return (
<View style={styles.container}>
<Image
style={styles.img}
source={require('./img/scrittaNera.png')}
onLoadStart={(e) => this.setState({loading: true})}
/>
<TouchableHighlight style={styles.button} onPress={this.onForward.bind(this)}>
<Text style={styles.buttonText}>Get Inspired</Text>
</TouchableHighlight>
</View>
);
}
}
Just remove Menu from
onForward(Menu) {
.
The parameter Menu shadows the component imported with import Menu from './Menu.ios';
.