模拟器未在React Native中更新

时间:2018-09-20 12:18:54

标签: javascript react-native simulator

我是本机的新手,在youTube上的每个教程中,他们只是将代码保存在代码编辑器中,并且只要重新加载模拟器,就可以在模拟器上进行更改。

但这对我不起作用。在我的情况下,模拟器显示唯一的启动屏幕,然后应用程序关闭
如果我尝试通过单击打开应用程序,它将显示错误屏幕,即使我删除该错误行代码并通过终端再次运行模拟器,错误屏幕也不会改变

下面是我的代码。

import React, {Component} from 'react'; 
import {Platform, StyleSheet, Text, View} from 'react-native'; 
import * as firebase from 'firebase';

    const firebaseConfig = { apiKey: "AIzaSyCoC87qeRN995YBOUrUDAcIVQS4i33FuY4", authDomain: "helloreactapp.firebaseapp.com", databaseURL: "https://helloreactapp.firebaseio.com", projectId: "helloreactapp", storageBucket: "helloreactapp.appspot.com", messagingSenderId: "180878232923" };

   const firebaseApp = firebase.initializeApp(firebaseConfig); import {Container, Content, Header, Form, Input, Item, Button, Label } from 'native-base';

    export default class App extends React.Component{

    constructor(props){   super(props)   this.state = ({
        email: '',
        password: ''   }) }

    signUpUser = (email,password) => {

      try {

        if(this.state.password.length<6){
          alert("please enter atleast 6 character")
        }

         firebase.auth().createUserWithEmailandPassword(email,password)

      } catch (error) {
        console.log(error.toString())   } }

      render() {
        return (
                 <Container styles={styles.container}>
                  <Form>
                    <Item floatingLabel>
                        <Label>Email</Label>
                          <Input
                          onChangeText={(email) => this.setState(email)}
                          />
                    </Item>
                    <Item floatingLabel>
                        <Label>Password</Label>
                          <Input
                          secureTextEntry={true}
                          onChangeText={(password) => this.setState(password)}
                          />
                    </Item>
                    <Button style={{marginTop: 10}}
                    full
                    rounded
                    primary
                    onPress = {() => this.signUpUser(this.state.email,this.state.password)}
                    ><Text>Sign Up</Text>
                    </Button>
                  </Form>
                 </Container>
        );   } }

    const styles = StyleSheet.create({   container: {
        flex: 1,
         justifyContent: 'center',
        backgroundColor: '#F5FCFF',
        padding: 18,   },   welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,   },   instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,   }, });

这是模拟器屏幕:enter image description here

2 个答案:

答案 0 :(得分:0)

Unexpected token, expected "}"似乎您在App文件中忘记了“}” ...错误也应该在Metro bundler窗口中可见...

答案 1 :(得分:0)

如果您在iOS模拟器上遇到这种情况,并且您已经尝试像这样import tqdm from tqdm for i in tqdm(range(s[0]), position=0, leave=True): check = True #build strings for each district ds = table.iloc[i,1] + str(table.iloc[i,2]) #testString = str(table.iloc[i,2]) #append ds to districtNames if it isnt in already #make array of District Objects for j in range(len(districtNames)): if(ds == districtNames[j]): check = False if(check): districtNames.append(ds) districts.append(District(ds,0)) 重新安装watchman,那么对我有用的是运行不同版本的模拟器,例如iPhone XS Max等