Complete the code to import Firebase in a React Native app.
import [1] from '@react-native-firebase/app';
The correct import is firebase from '@react-native-firebase/app' to use Firebase features.
Complete the code to initialize Firebase in your React Native app.
const app = [1]();You initialize Firebase with initializeApp() to connect your app to Firebase services.
Fix the error in the code to get a Firestore database instance.
const db = firebase.[1]();To get Firestore, use firebase.firestore(). 'database' is for Realtime Database, 'storage' for files, 'auth' for authentication.
Fill both blanks to write data to Firestore in React Native.
db.collection('[1]').[2]({ name: 'John' });
Use collection('users') to select the collection and add() to add a new document with data.
Fill all three blanks to listen for authentication state changes.
firebase.auth().[1]((user) => { if (user) { console.log('[2] logged in'); } else { console.log('[3] logged out'); } });
The method onAuthStateChanged listens for login/logout. The strings 'User' show who logged in or out.