繁体   English   中英

React-native - SyntaxError: ..\src\screens\SignUp.js: Unexpected token, 应为“;”

[英]React-native - SyntaxError: ..\src\screens\SignUp.js: Unexpected token, expected “;”

我是 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;

我在哪里犯错? 我一直在处理这个问题很长时间,感谢您的帮助。

如果您不使用 React.Component,请使用ArrowFunction

componentWillMount = ()=> {
const firebaseConfig = {
    apiKey: '****',
    authDomain: '****',
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM