Reactjs – module appregistry is not a registered callable module (calling runApplication)

react-nativereact-navigationreactjstabs

i cannot find a way to make react-navigation work at all. i copied the working examples from the internet but they don't seem to work too. can someone tell me what i am doing wrong.

i'm using
node: 8.9.4
react: 16.3.0-alpha.1
react-native: 0.54.0
react-navigation: ^1.4.0

//index.js
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {
  TabNavigator,
  StackNavigator
} from 'react-navigation';

import Home from './first';
import Homes from './second';

export default class demoApp extends Component {
  render() {
    return (
      <SimpleNavigation/>
    );
  }
}

export const SimpleNavigation = StackNavigator({
  Home: { 
    screen: Home,
    header: { visible: false },
    navigationOptions: {
      title: 'Home',
      header: null
    },
  },
  Homes: { 
    screen: Homes,
    navigationOptions: {
      title: 'second'
    },
  },
},{});

Here's the first tab

//first.js
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  Image,
  TextInput,
  Button,
  TouchableHighlight
} from 'react-native';

export default class Home extends Component {
    constructor(props){
        super(props);
        this.state = {zipCode: ''}
    }
    navigate = (zipCode) => {
        this.props.navigation.navigate('Search', zipCode);
    }
    render() {
        return (
            <View>
                <View>
                    <Text>An application to do things</Text>
                    <TextInput 

                        placeholder='Enter a Zip Code' 
                        onChangeText={(zipCode) => this.setState({zipCode})}
                        >
                    </TextInput>
                </View>
                <View>
                    <TouchableHighlight onPress={() => this.navigate(this.state.zipCode)}>
                        <Text>
                            Search
                        </Text>
                    </TouchableHighlight>
                </View>
            </View>
        );
    }
}

i cant seem to make it run at all. I tried following many other tutorials as well. But none of them worked. What am i doing wrong?

Best Answer

I kept getting this error too today, and it was very annoying. Was able to get rid of it by removing the Terminal window with "Metro" bundler stuff, and then recompiling the app.

Seems like it's not the code, but rather the runtime environment (which seems to work well with only one app example at a time). You can double check this by doing a super simple app that should work.

Related Topic