0 votes
in ReactJS by
What is the purpose of default value in context in ReactJS?

1 Answer

0 votes
by

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.

const MyContext = React.createContext(defaultValue);
...