github avatar

React18 Lifecycle Patterns

If you're still maintaining React class components and hitting UNSAFE_ warnings in 18.3.1, this gives you exact migration patterns for the three deprecated lifecycle methods. The decision tables are the real value here: they route you to the right replacement based on what the code actually does, not just which method name you're replacing. componentWillReceiveProps doing a fetch goes to componentDidUpdate, pure state derivation goes to getDerivedStateFromProps, and the guide is explicit about which is which. Saves you from the classic mistake of reaching for getDerivedStateFromProps when you actually need componentDidUpdate with a prev prop comparison. The references include full before and after code blocks for each case.

skills.sh installs
745
GitHub stars
41K
last updated
Aug 21, 2026

Install

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

Installs into .claude/skills of the current project.

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?

Sponsors

Details

Repository
github.com/github/awesome-copilot
Categories
Frontend Development, Git & Pull Requests, Documentation, AI & Agent Building, Productivity & Planning, Rust
First seen
May 16, 2026

More from github/awesome-copilot

All 318
1github avatarreact18-string-refsgithub/awesome-copilotProvides exact migration patterns for React string refs (ref="name" + this.refs.name) to React.createRef() in class components. Use this skill whenever migratin743skills.sh installs
221st-dev avataragent-elements21st-dev/agent-elementsUse whenever the user wants to build or modify a chat, agent, or tool-calling UI in a React 19 + Tailwind v4 project — especially if the code imports from `@/co733skills.sh installs
3vuetifyjs avatarvuetify0vuetifyjs/0Use when building Vue 3 UI that needs headless logic — selection state (single, multi, grouped, nested, stepped), form validation, registries, context providers730skills.sh installs
4hugorcd avatarreview-logging-patternshugorcd/evlogReview code for logging patterns and suggest evlog adoption. Optionally use @evlog/cli (`evlog init` to wire evlog, `evlog agents` to write the conventions into728skills.sh installs
5mindrally avatarstripemindrally/skillsStripe payment integration guidelines for TypeScript, React, Next.js with secure payment processing and subscription management728skills.sh installs
6mindrally avatarmonorepomindrally/skillsBest practices for monorepo development with TypeScript, React, Next.js, Expo, Turbo, and related technologies724skills.sh installs