【问题标题】:App is not updating for iPad Air 2, still showing error message应用程序未针对 iPad Air 2 更新,仍显示错误消息
【发布时间】:2019-02-22 11:33:46
【问题描述】:

我是 React Native 的新手。我遵循本教程https://www.youtube.com/watch?v=bZj6uzNRs5E&t=337s 将我的应用与 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>
    );
  }
}

如果有人知道,请帮助我。

【问题讨论】:

  • error.toString[] 应该是error.toString()

标签: javascript firebase react-native simulator


【解决方案1】:

我已经被卷入了几次。当您在代码中出错时,当 Metro 捆绑器重新捆绑 JavaScript 时,有时它会抛出错误并引发异常,并且不会更新您的代码。

如果您查看 Metro Bundler 窗口(在初始构建时打开并捆绑您的 JS 的窗口),可能会出现错误。我猜你的错误可能是:

error.toString[]

应该是:

error.toString()

正如下面的评论所暗示的,最好像

这样记录错误

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

【讨论】:

  • 如果您使用console.log(error)console.log(error.message),则日志效果会更好
  • @ShivamTrivedi - 错误是什么? (如果它给了你答案,你可以标记它/支持答案)
猜你喜欢
  • 2017-03-18
  • 2020-07-11
  • 2013-03-29
  • 2017-12-22
  • 2011-03-14
  • 2012-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多