Touch sophonara
Touch sophonara

Reputation: 80

react-native error after import firebase

I have installed firebase package in my project using cmd

npm install --save firebase 

When I import firebase to my react-native project import firebase from 'firebase' I'm getting this error. What could be the problem? enter image description here

Upvotes: 7

Views: 3855

Answers (3)

dolar
dolar

Reputation: 1785

Follow this pattern the error will be resolved the issue is due to upgradation in Firebase repo:

import React, {Component} from 'react';
import {Text, View} from 'react-native';
// import firebase from 'firebase';
import firebase from '@firebase/app'
import { Header } from './Components/Common';

Upvotes: 6

Syntax Hacker
Syntax Hacker

Reputation: 364

Ran into Same issue i solved it by installing babel polyfill

npm i --save-dev babel-polyfill

then in my index.js:

import 'babel-polyfill';

Upvotes: 1

Bhanuprakash Reddy
Bhanuprakash Reddy

Reputation: 67

thats because of the recent version of firebase you can roll back to version 4 or you can import like

import firebase from '@firebase/app'; any of the above two approaches will solve your problem

Upvotes: 0

Related Questions