react18-lifecycle-patterns

Provides exact before/after migration patterns for the three unsafe class component lifecycle methods - componentWillMount, componentWillReceiveProps, and…

INSTALLATION
npx skills add https://github.com/github/awesome-copilot --skill react18-lifecycle-patterns
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$28

What it does

Correct migration

Reference

Async side effect triggered by prop change (fetch, cancel)

componentDidUpdate

→ componentWillReceiveProps.md

Pure state derivation from new props (no side effects)

getDerivedStateFromProps

→ componentWillReceiveProps.md

componentWillUpdate - what does it do?

What it does

Correct migration

Reference

Reads the DOM before update (scroll, size, position)

getSnapshotBeforeUpdate

→ componentWillUpdate.md

Cancels requests / runs effects before update

componentDidUpdate with prev comparison

→ componentWillUpdate.md

The UNSAFE_ Prefix Rule

**Never use UNSAFE_componentWillMount, UNSAFE_componentWillReceiveProps, or UNSAFE_componentWillUpdate as a permanent fix.**

Prefixing suppresses the React 18.3.1 warning but does NOT:

  • Fix concurrent mode safety issues
  • Prepare the codebase for React 19 (where these are removed, with or without the prefix)
  • Fix the underlying semantic problem the migration is meant to address

The UNSAFE_ prefix is only appropriate as a temporary hold while scheduling the real migration sprint. Mark any UNSAFE_ prefix additions with:

// TODO: React 19 will remove this. Migrate before React 19 upgrade.

// UNSAFE_ prefix added temporarily - replace with componentDidMount / getDerivedStateFromProps / etc.

Reference Files

Read the full reference file for the lifecycle method you are migrating:

  • **references/componentWillMount.md** - 3 cases with full before/after code
  • **references/componentWillReceiveProps.md** - getDerivedStateFromProps trap warnings, full examples
  • **references/componentWillUpdate.md** - getSnapshotBeforeUpdate + componentDidUpdate pairing

Read the relevant file before writing any migration code.

BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card