New react native user here. I'm running into an issue and I am not sure how to proceed. I was able to get react-navigation running properly and then began receiving an error: "The component for route must be a a React Component" but unless I'm missing something, I believe that the component I am referencing is a react component. See my index.android.js below and my Home.js below:
//index.android.js
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {
  TabNavigator,
  StackNavigator
} from 'react-navigation';
import Home from './app/components/Home/Home';
import Search from './app/components/Search/Search';
export default class demoApp extends Component {
  render() {
    return (
      <SimpleNavigation/>
    );
  }
}
export const SimpleNavigation = StackNavigator({
  Home: { 
    screen: Home,
    header: { visible: false },
    navigationOptions: {
      title: 'Home',
      header: null
    },
  },
  Search: { 
    screen: Search,
    navigationOptions: {
      title: 'test'
    },
  },
},{});
//Home.js
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  TouchableHighlight
} from 'react-native';
class Home extends Component {
    constructor(props){
        super(props);
        this.state = {zipCode: ''}
    }
    navigate = (zipCode) => {
        this.props.navigation.navigate('Search', zipCode);
    }
    render() {
        return (
            <View style={styles.container}>
                <View style={[styles.boxContainer, styles.boxOne]}>
                    <Image style={styles.logo} source {require('../../images/Logo.png')} />
                    <Text style={styles.title}>An application to do things</Text>
                    <TextInput 
                        style={styles.textInput} 
                        placeholder='Enter a Zip Code' 
                        onChangeText={(zipCode) => this.setState({zipCode})}
                        >
                    </TextInput>
                </View>
                <View style={[styles.boxContainer, styles.boxTwo]}>
                    <TouchableHighlight onPress={() => this.navigate(this.state.zipCode)}>
                        <Text style={styles.searchBox}>
                            Search
                        </Text>
                    </TouchableHighlight>
                </View>
            </View>
        );
    }
}

Any help/react pointers much appreciated. Thank you!
This might happen if you have an old version of the metro-react-native-babel-preset package. Try upgrading it to the latest version. If you have @babel/core installed, also upgrade it to latest version.
React Navigation is a popular library for routing and navigation in a React Native application. This library helps solve the problem of navigating between multiple screens and sharing data between them.
I think the problem is with home.js since you aren't exporting it. Try this :
export default class Home extends Component { ... } 
^^^^^^^^^^^^^^
Add those or just add
 export default Home; 
at the end of the home.js file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With