应用未针对 iPad Air 2 更新,仍显示错误消息

App is not updating for iPad Air 2, still showing error message

我是 React Native 的新手。我遵循本教程 https://www.youtube.com/watch?v=bZj6uzNRs5E&t=337s link 我的 Firebase 应用。

但是我的应用显示错误 "Unexpected Token (31:13)"

我更新了我的代码并保存了 仍然,我收到相同的错误消息。 我多次更改我的代码,但每次都出现相同的错误消息。

下面是完整的app.js代码代码

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, View} from 'react-native';
import * as firebase from 'firebase'; 
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 = ({
//    firstName='',
  //  lastName='',
    email='',
    password=''
    //confirmPassword='',

  })
}

signUpUser = (/*firstName,lastName,*/email,password/*,confirmPassword*/) => {

  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>First Name</Label>
                    <Input
                    autoCorrect={false}
                    autoCapitalize='none'
                    onChangeText={(firstName) => this.setState{(firstName)}}
                    />
              </Item>
              <Item floatingLabel>
                  <Label>Last Name</Label>
                    <Input
                    autoCorrect={false}
                    autoCapitalize='none'
                    onChangeText={(lastName) => this.setState{(lastName)}}
                    />
              </Item>
                <Item floatingLabel>
                    <Label>Email</Label>
                      <Input
                      autoCorrect={false}
                      autoCapitalize='none'
                      onChangeText={(email) => this.setState{(email)}}
                      />
                </Item>
                <Item floatingLabel>
                    <Label>Password</Label>
                      <Input
                      secureTextEntry={true}
                      autoCorrect={false}
                      autoCapitalize='none'
                      onChangeText={(password) => this.setState{(password)}}
                      />
                </Item>
                <Item floatingLabel>
                    <Label>Confirm Password</Label>
                      <Input
                      secureTextEntry={true}
                      autoCorrect={false}
                      autoCapitalize='none'
                      onChangeText={(confirmPassword) => this.setState{(confirmPassword)}}
                      />
                </Item>
                <Button style={{marginTop: 10}}
                full
                rounded
                success
                onPress = {() => this.signUpUser(this.state.email,/* this.state.firstName, this.state.lastName,*/this.state.password/*,this.state.confirmPassword*/)}
                ><Text>Sign Up</Text>
                </Button>

              </Form>
             </Container>
    );
  }
}

有知道的请帮帮我

我被困在这个问题上好几次了。当您在代码中出错时,当 metro 捆绑器重新捆绑 JavaScript 时,有时它会抛出异常错误并且不会更新您的代码。

如果您查看 Metro Bundler window(在初始构建时打开并捆绑您的 JS 的那个),它可能在那里有错误。我猜你的错误可能是:

error.toString[]

应该是:

error.toString()

正如下面的评论所建议的那样,最好将错误记录为

console.log(error)console.log(error.message)