0
0
Firebasecloud~10 mins

Modular SDK (v9+) tree-shaking in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import only the Firestore function needed to get a document.

Firebase
import { getDoc, [1] } from 'firebase/firestore';
Drag options to blanks, or click blank then click option'
AinitializeApp
Bcollection
CgetDocs
Ddoc
Attempts:
3 left
💡 Hint
Common Mistakes
Importing the entire Firestore module instead of specific functions.
Using 'collection' when you need a document reference.
2fill in blank
medium

Complete the code to initialize Firebase app with the modular SDK.

Firebase
import { initializeApp } from 'firebase/app';

const firebaseConfig = { /* config values */ };
const app = [1](firebaseConfig);
Drag options to blanks, or click blank then click option'
AinitializeApp
BgetApp
CcreateApp
DstartApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using getApp before initializing the app.
Trying to use non-existent functions like createApp or startApp.
3fill in blank
hard

Fix the error in importing Firestore functions for reading a document.

Firebase
import { getDoc, doc, [1] } from 'firebase/firestore';
Drag options to blanks, or click blank then click option'
AinitializeApp
Bcollection
CgetDocs
DgetDoc
Attempts:
3 left
💡 Hint
Common Mistakes
Importing getDoc twice.
Importing initializeApp from Firestore instead of 'firebase/app'.
4fill in blank
hard

Fill both blanks to create a Firestore document reference and read it.

Firebase
import { getFirestore, [1], [2] } from 'firebase/firestore';

const db = getFirestore(app);
const docRef = [1](db, 'users', 'user123');
const docSnap = await [2](docRef);
Drag options to blanks, or click blank then click option'
Adoc
BgetDoc
Ccollection
DinitializeApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using collection instead of doc for document references.
Mixing up getDoc and getDocs.
5fill in blank
hard

Fill all three blanks to import, initialize, and get a Firestore document using modular SDK.

Firebase
import { [1] } from 'firebase/app';
import { getFirestore, [2], [3] } from 'firebase/firestore';

const app = [1](firebaseConfig);
const db = getFirestore(app);
const docRef = [2](db, 'products', 'prod001');
const docSnap = await [3](docRef);
Drag options to blanks, or click blank then click option'
AinitializeApp
Bdoc
CgetDoc
Dcollection
Attempts:
3 left
💡 Hint
Common Mistakes
Importing and calling initializeApp incorrectly.
Using collection instead of doc for document references.
Confusing getDoc with getDocs.