Challenge - 5 Problems
Firebase Setup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ ui_behavior
intermediate2:00remaining
Firebase Initialization Behavior
After correctly installing and configuring @react-native-firebase/app, what will be the output of this code snippet in a React Native app?
React Native
import React from 'react'; import {Text, View} from 'react-native'; import firebase from '@react-native-firebase/app'; export default function App() { const isInitialized = firebase.apps.length > 0; return ( <View> <Text>{isInitialized ? 'Firebase Initialized' : 'Firebase Not Initialized'}</Text> </View> ); }
Attempts:
2 left
💡 Hint
Check if the firebase.apps array contains initialized apps after setup.
✗ Incorrect
The @react-native-firebase/app package initializes Firebase automatically if configured correctly. The apps array contains initialized Firebase app instances. If length > 0, Firebase is initialized.
📝 Syntax
intermediate1:30remaining
Correct Import for Firebase Firestore
Which import statement correctly imports Firestore from @react-native-firebase for use in a React Native app?
Attempts:
2 left
💡 Hint
Check the official package name for Firestore in react-native-firebase.
✗ Incorrect
The Firestore module is imported as default from '@react-native-firebase/firestore'. Named imports or importing from '@react-native-firebase/app' won't work for Firestore.
❓ lifecycle
advanced2:00remaining
Effect of Missing GoogleService-Info.plist or google-services.json
What happens if you run a React Native app with @react-native-firebase/app installed but forget to add the GoogleService-Info.plist (iOS) or google-services.json (Android) files?
Attempts:
2 left
💡 Hint
Think about what Firebase needs to connect to your project.
✗ Incorrect
Without the config files, Firebase cannot connect to your project backend. Initialization may succeed but calls to services like Firestore or Auth will fail at runtime.
advanced
2:30remaining
Navigating After Firebase Auth State Change
In a React Native app using @react-native-firebase/auth, which code snippet correctly listens for user sign-in state changes and navigates to 'Home' screen when signed in?
Attempts:
2 left
💡 Hint
Remember to clean up listeners in useEffect to avoid memory leaks.
✗ Incorrect
Option D correctly sets up the listener inside useEffect and returns the unsubscribe function to clean up. It navigates to 'Home' only if user is signed in.
🔧 Debug
expert3:00remaining
Debugging Firebase Module Not Found Error
You installed @react-native-firebase/app and @react-native-firebase/auth, but when running your React Native app, you get the error: "Module '@react-native-firebase/auth' not found". What is the most likely cause?
Attempts:
2 left
💡 Hint
Think about native module linking steps for iOS after adding new packages.
✗ Incorrect
After installing new native modules in React Native, especially on iOS, you must run 'pod install' in the ios folder to link native code. Missing this causes module not found errors.