useEffect runs side effects after rendering and replaces many class lifecycle use cases in function components.
- Effects run after render
- Dependency arrays control when they re-run
- Effects should synchronize with the outside world
useEffect behavior depends heavily on its dependency array, and many common bugs come from missing dependencies or stale captured values.
- No dependency array means after every render
- Empty array means mount-like behavior
- Cleanup prevents leaks and duplicate subscriptions
These hooks and helpers solve timing, refs, deferred rendering, and stable identity concerns that basic hooks do not cover.
- useLayoutEffect runs earlier than useEffect
- forwardRef exposes refs across component boundaries
- Transition hooks help prioritize urgent updates
React memoization tools help avoid unnecessary work, but they only help when they stabilize expensive calculations or props meaningfully.
- useMemo caches values
- useCallback caches function identities
- React.memo skips re-renders for unchanged props
useRef holds mutable values that do not trigger re-renders and is commonly used for DOM access or persistent instance-like values.
- Refs do not cause re-renders
- Useful for DOM nodes and mutable escape hatches
- State should drive visible UI
useState stores local component state, and updates should be based on immutable patterns and previous state when needed.
- Use functional updates when next state depends on previous state
- Never mutate arrays or objects directly
- Setter calls schedule a re-render
Object and array state require immutable updates, and using multiple state variables can sometimes be clearer than one large state object.
- Spread or mapping is common for immutable updates
- Separate state can improve clarity
- One object is not always better
React compares virtual tree snapshots, reconciles differences, and updates the real DOM only where needed.
- Virtual DOM is an in-memory representation
- Reconciliation decides what changed
- Diffing avoids blind full-DOM replacement
`agg` reduces groups, `transform` returns group-shaped output, and `apply` handles custom logic but is usually slower.
- agg changes shape
- transform keeps original row count
- apply is flexible but costly
Inspect null patterns first, then choose to drop, fill, or flag them based on meaning.
- Use isna to inspect
- fillna or dropna depending on business meaning
- Missingness itself can be informative
`loc` selects by labels and `iloc` selects by integer position.
- loc uses labels
- iloc uses zero-based positions
- Slices behave differently for labels vs positions
`merge` combines rows by key columns, `join` is index-oriented sugar, and `concat` stacks objects along an axis.
- merge is SQL-like
- join defaults to index alignment
- concat appends rows or columns