💡 Why Use Global Context?
Imagine you have an app with many components and want to share user login status, theme (dark/light), or language settings across all of them. Instead of sending that data as props through each level, you can use Context to create a global state.
✅ Goal:
-
Input in
Header.js
-
Display in
Footer.js
-
Shared state using Context inside
App.js
🧩 File 1: App.js
🧩 File 2: Header.js
🧩 File 3: Footer.js
✅ What this does:
-
App.js
holds the global context state. -
Header.js
updates the context when you type. -
Footer.js
displays the current value from the context.