【发布时间】: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