I am new to setting up firebase in react native and I want to initialize a second configuration in firebase but I am having an error.
This is my code:
const secondaryAppConfig = { apiKey: ..., authDomain: ..., databaseURL: ..., projected: ..., storageBucket: ..., messagingSenderId: ..., appId: ..., measurements: ... }; const secondaryApp = firebase.initializeApp(secondaryAppConfig, 'secondary'); secondaryApp.database() .ref(`test`) .on('value', (snap) => { const test = snap.val(); console.log(test.sample); });
This is the error that shows:
Exception 'nil FIRApp instance passed to databaseForApp.' was thrown while invoking on on target RNFirebaseDatabase with params ( SECOND,"...", { appName = SECONDARY; eventType = value; hasCancellationCallback = 0; key = "..."; modifiers = ( ); path = test; registration = { eventRegistrationKey = "..."; key = "..."; registrationCancellationKey = "..."; }; })