Term | |
---|---|
context | a method to pass props from parent to child component(s), by storing the props in a store(similar in Redux) and using these props from the store by child component(s) without actually passing them manually at each level of the component tree |
useContext() | create common data that can be accessed throughout the component hierarchy without passing the props down manually to each level |
static context | which wraps our component with PureComponent shallow comparison logic while also allowing us to pass references from our context |
“Context is primarily used when some data needs to be accessible by many components at different nesting levels. Apply it sparingly because it makes component reuse more difficult”.
“If you only want to avoid passing some props through many levels, component composition is often a simpler solution than context”.