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

点点圈 提交于 2020-01-06 05:51:07

问题


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?


回答1:


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.




回答2:


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




回答3:


Close your Nodejs Terminal and run again



来源:https://stackoverflow.com/questions/49128692/module-appregistry-is-not-a-registered-callable-module-calling-runapplication

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!