Bhol
Bhol

Reputation: 145

InitializeApp firebase in react native: Error "Unexpected token

Got error while initializing Firebase configuration in expo react native. Unexpected token ";"

Enviroment: Expo development React native firebase visual studio code editor

What I want: I am new , learning how to authenticate /login in react native application using firebase email/password method.

What I did: In the code editor tool--> app.js--> I imported the firebase , created a const to define the firebase config parameters.

After that, I tried to initialize firebase .

What is the issue:

When I ran the app on my phone , the following error occurred.

SyntaxError: C:\Users\Jituni\bholmentorworld\App.js: Unexpected token, expected ";" (32:23)

30 | }; 31 |

32 | firebase.initializeApp{firebaseConfig}; | ^ 33 | 34 | export default class App extends React.Component{

35 |

[import React from "react";
import { Image, Button, TextInput, ScrollView, Stylesheet, Text, View } from "react-native";

import * as firebase from 'firebase';


const firebaseConfig={
  apiKey:"AIzaSyDimdV7iWkVaLKpQVqt82_TiSuRA0NBAOE",
  authDomain:"firebaseapp",
  databaseURL:"mentordunia",
  projectId:"mentordunia",
  storageBucket:"",
  messagingSenderId:"1055433782606",
  appId:"b308d4b9d990db06",
};

 firebase.initializeApp{firebaseConfig};

export default class App extends React.Component{


render() {
return <AppContainer/>;
 }
};][1]

Expected result: Should not receive error to initialize firebase

Actual result: Error in initialing firebase

Upvotes: 0

Views: 1681

Answers (1)

joseluismurillorios
joseluismurillorios

Reputation: 1014

I recommend using a linter to catch any possible error, I personally use eslint with vs code.

firebase.initializeApp{firebaseConfig}; should be firebase.initializeApp(firebaseConfig);

Upvotes: 2

Related Questions