【问题标题】:React-native - SyntaxError: ..\src\screens\SignUp.js: Unexpected token, expected ";"React-native - SyntaxError: ..\src\screens\SignUp.js: Unexpected token, expected ";"
【发布时间】:2019-10-24 10:49:22
【问题描述】:

我是 react native 的初学者。我有个问题。我正在尝试使用 firebase 设置注册页面,但我无法做到这一点。有一个编译器错误,即 Unexpected token, expected ";" (29:21) 这是我的 SignUp.js 页面

import React from 'react';
import Firebase from 'firebase';

import {
  SafeAreaView,
  StyleSheet,
  ScrollView,
  View,
  Text,
  StatusBar,
  Image,
  Alert,
  Button

} from 'react-native';

import {
  Header,
  LearnMoreLinks,
  Colors,
  DebugInstructions,
  ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import SignUpNextBtn from '../components/SignUpNextBtn';
import Input from '../components/Input';

const SignUp: () => React$Node = () => {

componentWillMount() {
    const firebaseConfig = {
        apiKey: '****',
        authDomain: '****',
}
    firebase.initializeApp(firebaseConfig);
}

  return (
    <>
    <View style={styles.container}>
            <Input />
            <View style={styles.headBackground}>
                <Text>Sign Up</Text>
                <Text style={styles.logo}>Sign Up to{'\n'}GOLD#</Text>
                <Text style={styles.logoDescription}>Sign Up</Text>
            </View>
            <ScrollView>
                <View  style={styles.loginArea}>
                    <Image style={styles.userCheckImg} source={require('../assets/user-check.png')}/>
                    <Image style={styles.envelopeImg} source={require('../assets/envelope-alt.png')}/>
                    <Image style={styles.lockImg} source={require('../assets/lock-alt.png')}/>
                    <Image style={styles.mobileImg} source={require('../assets/mobile-android-alt.png')}/>
                    <Image style={styles.postcardImg} source={require('../assets/postcard.png')}/>
                    <Text>Welcome !</Text>
                    <Text>{'\n'}Name* </Text>
                    <Input />
                    <Text>Email* </Text>
                    <Input />
                    <Text>PIN* </Text>
                    <Input secureTextEntry={true}/>
                    <Text>ID </Text>
                    <Input />
                    <Text>Phone Number </Text>
                    <Input />
                </View>
            </ScrollView>
            <SignUpNextBtn />
        </View>
    </>
  );
};


const styles = StyleSheet.create({

  container: {
      flex: 1,
      paddingVertical:80,
      backgroundColor: '#F5FCFF',
    },
    headBackground: {
          position:"absolute",
          top:0,
          left:0,
          height:560,
          width:411,
          backgroundColor:'#F3EA79',

        },

    logo:{
        textAlign:'center',
        fontSize:40,
        fontWeight:'bold',
        color:'#FFF',
        width:200,
        height:100,
        top:10,
        left:45,


    },
    logoDescription:{
        textAlign:'center',
        color:'#f2f2f2'
    },
    loginArea:{
        marginHorizontal:40,
        marginVertical:40,
        backgroundColor:'#fff',
        padding:20,
        borderRadius:10,
        elevation:10
    },
    userCheckImg: {
            width: 15,
            height: 12.75,
            top:125,
            left:5,
            position:"absolute",
            alignItems:'flex-start'
          },
    envelopeImg: {
                width: 15,
                height: 12.75,
                top:215,
                left:5,
                position:"absolute",
                alignItems:'flex-start'
              },
    lockImg: {

                width: 15,
                height: 12,
                top:305,
                left:5,
                position:"absolute",
                alignItems:'flex-start'
              },
    postcardImg: {
                    width: 15,
                    height: 12.75,
                    top:395,
                    left:5,
                    position:"absolute",
                    alignItems:'flex-start'
                  },
    mobileImg: {
                width: 15,
                height: 12.75,
                top:480,
                left:5,
                position:"absolute",
                alignItems:'flex-start'
              },

});

export default SignUp;

我在哪里犯了错误?解决这个问题很久了,谢谢大家的帮助。

【问题讨论】:

  • ReloadInstructions, 结尾是假逗号

标签: javascript android firebase react-native


【解决方案1】:

如果您不使用 React.Component

,请使用 ArrowFunction
componentWillMount = ()=> {
const firebaseConfig = {
    apiKey: '****',
    authDomain: '****',
}

【讨论】:

    猜你喜欢
    • 2017-12-09
    • 1970-01-01
    • 2020-08-15
    • 2017-09-16
    • 2021-08-05
    • 2016-07-25
    • 2019-08-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多