Callback Refs vs Object Refs in React
Object refs hold a node in a current property, while callback refs run a function whenever a node attaches or detaches. Learn which fits your case.
Build modern UIs with React
Object refs hold a node in a current property, while callback refs run a function whenever a node attaches or detaches. Learn which fits your case.
Give an imperative library a container element through a ref, initialize it in an Effect after commit, and destroy it in the cleanup.
Diagnose the common React ref errors, from null current values to unforwarded refs and conditional nodes, with a fix for each.
Type the useRef Hook correctly in TypeScript: useRef now requires an argument and returns one mutable RefObject type for both DOM nodes and plain values.
Create a context with createContext, provide a value through a provider, and read it with useContext to share data across a React component tree.
Choose between a meaningful fallback default and a custom hook that throws, so a missing React context provider fails loudly instead of silently.
Recognize prop drilling, decide when it is worth fixing, and apply composition or context to stop threading unused props through the tree.
Props flow explicitly from parent to child, while context shares a value with any reader below a provider. Learn which to reach for and when.
Keep context state in a provider component and pass the value with its setter, so child components can read and update shared state.
Combine several React context providers into one provider component so the tree stays readable as your app collects more shared values.
Context re-renders every component that reads it when the value changes. Learn why and how to reduce the work with useMemo and useCallback.
Spot the recurring React context mistakes, from treating it as a global store to recreating the value, and apply the smaller, clearer pattern.