Skip to content

Latest commit

 

History

History
25 lines (13 loc) · 636 Bytes

useContext.md

File metadata and controls

25 lines (13 loc) · 636 Bytes

useContext

Intro

Context is a form of Dependency Injection. It is a transport mechanism - it doesn't "manage" anything. Any "state management" is done by you and your own code, typically via useState/useReducer.

as stated here

Custom context hooks

UNDER CONSTRUCTION

Context Provider HOC

UNDER CONSTRUCTION

How to avoid unncecessary re-renders

Split your context into multiple contexts

See https://react.dev/learn/scaling-up-with-reducer-and-context

useMemo your context value

ThemeConsumer component with React.memo