Loading...
Loading...
Provides exact before/after migration patterns for the three unsafe class component lifecycle methods - componentWillMount, componentWillReceiveProps, and componentWillUpdate - targeting React 18.3.1. Use this skill whenever a class component needs its lifecycle methods migrated, when deciding between getDerivedStateFromProps vs componentDidUpdate, when adding getSnapshotBeforeUpdate, or when fixing React 18 UNSAFE_ lifecycle warnings. Always use this skill before writing any lifecycle migration code - do not guess the pattern from memory, the decision trees here prevent the most common migration mistakes.
npx skill4agent add github/awesome-copilot react18-lifecycle-patterns| What it does | Correct migration | Reference |
|---|---|---|
Sets initial state ( | Move to | → componentWillMount.md |
| Runs a side effect (fetch, subscription, DOM) | Move to | → componentWillMount.md |
| Derives initial state from props | Move to | → componentWillMount.md |
| What it does | Correct migration | Reference |
|---|---|---|
| Async side effect triggered by prop change (fetch, cancel) | | → componentWillReceiveProps.md |
| Pure state derivation from new props (no side effects) | | → componentWillReceiveProps.md |
| What it does | Correct migration | Reference |
|---|---|---|
| Reads the DOM before update (scroll, size, position) | | → componentWillUpdate.md |
| Cancels requests / runs effects before update | | → componentWillUpdate.md |
UNSAFE_componentWillMountUNSAFE_componentWillReceivePropsUNSAFE_componentWillUpdate// TODO: React 19 will remove this. Migrate before React 19 upgrade.
// UNSAFE_ prefix added temporarily - replace with componentDidMount / getDerivedStateFromProps / etc.references/componentWillMount.mdreferences/componentWillReceiveProps.mdreferences/componentWillUpdate.md