InterviewHubPRO
Section Overview
Q199

Question 199 of 445

Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

45%
React & Modern Frontend (445 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

What is the purpose of default value in context?

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);