2017-09-14 149 views
-3

我找不到这里有什么问题:https://hastebin.com/fuwofavuso.scala(我不能在这里发布,我不想缩进所有行)。反应原生代码does not execute

import React, { Component} from 'react'; 
import { Text, View, StyleSheet, Image, TextInput, AppRegistry} from 'react-native'; 
import { Constants, BlurView } from 'expo'; 

export default class App extends Component { 
    render() { 
    return (
     <View style={{ height: 200, width: 300 }}> 
     <InputText/> 
     </View> 
    ); 
    } 
} 

class InputText extends Component { 
    constructor(props) { 
    super(props); 

    this.state = { 
     text: 'lel', 
    }; 
    } 

    render() { 
    return (
     <div> 
     <TextInput 
      onChangeText={(text) => this.setState({ text })} 
      value={this.state.text} 
     /> 
     <Text value={this.state.text}></Text> 
     </div> 
    ); 
    } 
} 

const styles = StyleSheet.create({ 
    container: { 
    flex: 1, 
    alignItems: 'center', 
    justifyContent: 'center', 
    paddingTop: Constants.statusBarHeight, 
    backgroundColor: '#ecf0f1', 
    }, 
    paragraph: { 
    margin: 24, 
    fontSize: 18, 
    fontWeight: 'bold', 
    textAlign: 'center', 
    color: '#34495e', 
    }, 
}); 
AppRegistry.registerComponent('Unknown Snack',() => InputText); 

我的错误是:

不确定是不是一个对象评估_reactnative.appregistry.registerComponent()

我运行它世博小吃

+0

*“不想缩进所有行”* - 突出显示代码并单击一个按钮太费力了? – JJJ

+0

你如何运行它? – parohy

+0

诚实的建议;当问别人寻求帮助时,你应该投入尽可能多的努力,作为回报。你已经把你的代码粘贴在一个链接后面,并且没有指出你已经做出了什么样的尝试来解决这个问题。所以我会给你一个同样努力的答案; “它看起来像你的AppRegistry组件导入不工作”。 – gravityplanx

回答

0

正如你可以看到hereregisterComponent函数有两个参数,第二个参数是你的主要组件,在你的情况下,组件的名称似乎是错的(你的问题可能是因为这个)。我认为你的代码应该是这样的:

AppRegistry.registerComponent('yourAppKey', App); 
+0

好的,谢谢,我想它是因为我用世博会小吃! – NightScap3