1

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?

Anita
  • 476
  • 3
  • 10
  • 24
  • 1
    You may try the solution as mentioned [here](https://stackoverflow.com/questions/34969858/react-native-module-appregistry-is-not-a-registered-callable-module) – Pritish Vaidya Mar 07 '18 at 09:55
  • Resolved in my case in https://stackoverflow.com/a/65337406/6318705 , maybe you can ref to. – Li Zheng Dec 18 '20 at 00:16

3 Answers3

12

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.

xke
  • 1,073
  • 12
  • 13
  • I had to also click the drop-down on the device in Android Virtual Device Manager and select Wipe Data and restart it. – PeterM Sep 23 '19 at 14:00
2

Close your Nodejs Terminal and run again

1

Just kill all node process and start npm server and run application:

Step1: run command killall -9 node

Step2: run command npm start

Step3: run command react-native run-ios OR react-native run-android

Mohsen Fard
  • 597
  • 9
  • 22