Govan
Govan

Reputation: 1389

import conflict two module react native

I have two module firebase and react-native-firebase I want import both ,how can do that?

import  firebase from 'firebase'

import {firebase as firebase2} from 'react-native-firebase';

when i want use it const messaging=firebase2.messaging()

error:Unhandled JS Exception: TypeError: undefined is not an object (evaluating '_reactNativeFirebase.firebase.messaging')

Upvotes: 2

Views: 139

Answers (1)

mansour lotfi
mansour lotfi

Reputation: 602

Import the Messaging package into your project:

import messaging from '@react-native-firebase/messaging';

The package also provides access to the firebase instance:

import { firebase as firebase2 } from '@react-native-firebase/messaging';

Upvotes: 1

Related Questions