Questions and answers
The following are some questions and answers to refresh your knowledge:
- What is a React context?
A React context is an identity that can be used to share a value with consumers. It's designed so that a value can be provided to a localized scope, hence all components within that scope can read from this shared value.
- What is the
useContext
hook?The
useContext
hook is used in a consumer component so that it can read a context given by providers. A component can consume as many contexts as it can. When the provider gets updated, all the consumer components for that particular context get updated at the same time. - What's the common usage of
useContext
?The
useContext
hook is a hook in the React hook family when it comes to an update involving an area of components. We often see this context usage inUser
,Theme
, andTable
, which requires the consumption of a value under an ancestor component without passing it explicitly through layers of...