Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
github avatar

React18 Lifecycle Patterns

  • 745 installs
  • 37.1k repo stars
  • Updated July 28, 2026
  • github/awesome-copilot

react18-lifecycle-patterns migrates componentWillMount, componentWillReceiveProps, and componentWillUpdate to safe React 18 equivalents.

About

React 18 Lifecycle Patterns routes each unsafe lifecycle method to the correct modern replacement based on semantic intent rather than name matching alone. componentWillMount moves initial state to constructor, side effects to componentDidMount, or prop-derived state to constructor with props. componentWillReceiveProps becomes componentDidUpdate for async side effects or getDerivedStateFromProps for pure prop-to-state derivation with trap warnings in references. componentWillUpdate maps DOM reads before paint to getSnapshotBeforeUpdate paired with componentDidUpdate, or effect cancellation to componentDidUpdate with previous prop comparison. The UNSAFE_ prefix rule rejects permanent suppression because it does not fix concurrent safety or prepare for React 19 removal.

  • Decision tables route each unsafe method by semantic category, not name alone.
  • componentWillMount: constructor for state, didMount for effects, constructor(props) for derivation.
  • componentWillReceiveProps: didUpdate for async, getDerivedStateFromProps for pure state sync.
  • componentWillUpdate: getSnapshotBeforeUpdate for DOM reads before update.
  • UNSAFE_ prefix is temporary only; React 19 removes these methods entirely.

React18 Lifecycle Patterns by the numbers

  • 745 all-time installs (skills.sh)
  • +17 installs in the week ending Jul 17, 2026 (Skillselion tracking)
  • Ranked #459 of 2,277 Frontend Development skills by installs in the Skillselion catalog
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
At a glance

react18-lifecycle-patterns capabilities & compatibility

Capabilities
semantic routing tables per unsafe lifecycle met · constructor versus didmount versus didupdate sel · getderivedstatefromprops versus didupdate distin · getsnapshotbeforeupdate dom read migration patte · unsafe_ prefix temporary hold policy with todo c
Use cases
refactoring · testing
From the docs

What react18-lifecycle-patterns says it does

Wrong category = wrong migration.
SKILL.md
React 19 will remove this. Migrate before React 19 upgrade.
SKILL.md
npx skills add https://github.com/github/awesome-copilot --skill react18-lifecycle-patterns

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs745
repo stars37.1k
Security audit3 / 3 scanners passed
Last updatedJuly 28, 2026
Repositorygithub/awesome-copilot

Which modern lifecycle replaces an unsafe method when the old code mixes state, effects, and DOM reads?

Migrate unsafe class lifecycle methods componentWillMount, componentWillReceiveProps, and componentWillUpdate to React 18.3.1 compliant patterns.

Who is it for?

Class components with UNSAFE_ lifecycle warnings during React 18.3.1 upgrades.

Skip if: Skip for function components with hooks, string refs, or dependency compatibility checks.

When should I use this skill?

User migrates componentWillMount, componentWillReceiveProps, componentWillUpdate, or sees UNSAFE_ warnings.

What you get

Semantic decision tables pointing to constructor, didMount, didUpdate, getDerivedStateFromProps, or getSnapshotBeforeUpdate.

  • refactored class component code
  • lifecycle migration pattern reference

Files

SKILL.mdMarkdownGitHub ↗

React 18 Lifecycle Patterns

Reference for migrating the three unsafe class component lifecycle methods to React 18.3.1 compliant patterns.

Quick Decision Guide

Before migrating any lifecycle method, identify the semantic category of what the method does. Wrong category = wrong migration. The table below routes you to the correct reference file.

componentWillMount - what does it do?

What it doesCorrect migrationReference
Sets initial state (this.setState(...))Move to constructor→ componentWillMount.md
Runs a side effect (fetch, subscription, DOM)Move to componentDidMount→ componentWillMount.md
Derives initial state from propsMove to constructor with props→ componentWillMount.md

componentWillReceiveProps - what does it do?

What it doesCorrect migrationReference
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 doesCorrect migrationReference
Reads the DOM before update (scroll, size, position)getSnapshotBeforeUpdate→ componentWillUpdate.md
Cancels requests / runs effects before updatecomponentDidUpdate 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.

Related skills

How it compares

Pick react18-lifecycle-patterns for surgical class-component lifecycle migrations; use broader React upgrade skills when converting entire codebases from classes to hooks.

FAQ

Is UNSAFE_ prefix a valid permanent fix?

No. It suppresses warnings but does not fix concurrent issues and React 19 removes the methods anyway.

Prop change triggers fetch - which replacement?

Use componentDidUpdate for async side effects triggered by prop changes.

Need scroll position before DOM update?

Use getSnapshotBeforeUpdate for DOM reads, paired with componentDidUpdate for applying changes.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.