React Core & Hooks (407 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)
What is the purpose of default value in context?
junior LevelCode ExampleFormsPerformance
The defaultValue argument is only used when a component does not have a matching Provider above it in the tree. This can be helpful for testing components in isolation without wrapping them.
Below code snippet provides default theme value as Luna.
javascript
const MyContext = React.createContext(defaultValue);