New advertisers: 50% off your first month with code FIRSTMONTHSee slots
github avatar

React18 Lifecycle Patterns

Migrates the three unsafe class lifecycle methods to React 18.3.1 patterns using semantic decision tables.

skills.sh installs
746
GitHub stars
41.4K
last updated
Aug 21, 2026
View on GitHub

What it does

  • Covers componentWillMount, componentWillReceiveProps, and componentWillUpdate, routing each by what the method actually does to its correct replacement
  • Includes three reference files with before and after code for each lifecycle method, plus getDerivedStateFromProps trap warnings
  • Enforces a rule against permanent UNSAFE_ prefixes and requires a TODO comment on any temporary prefix that is added
  • Designed for codebases migrating class components before a React 19 upgrade, where the right pattern depends on the method's semantics

Install

$ npx -y skills add github/awesome-copilot --skill react18-lifecycle-patterns -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

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?

Details

Repository
github.com/github/awesome-copilot
Category
Frontend & UI Code
First seen
May 16, 2026

More from github/awesome-copilot

All 293

Similar to React18 Lifecycle Patterns

More Frontend & UI Code