模块 appregistry 不是注册的可调用模块(调用 runApplication) [英] module appregistry is not a registered callable module (calling runApplication)

查看:54
本文介绍了模块 appregistry 不是注册的可调用模块(调用 runApplication)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我根本找不到让 react-navigation 工作的方法.我从互联网上复制了工作示例,但它们似乎也不起作用.谁能告诉我我做错了什么.

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.

我正在使用节点:8.9.4反应:16.3.0-alpha.1反应原生:0.54.0反应导航:^1.4.0

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'
    },
  },
},{});

这是第一个标签

//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?

推荐答案

我今天也一直收到这个错误,非常烦人.能够通过删除带有Metro"捆绑程序内容的终端窗口,然后重新编译应用程序来摆脱它.

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.

这篇关于模块 appregistry 不是注册的可调用模块(调用 runApplication)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆