⚠️ This tool is under active development. Some advanced features described below are in progress and not yet fully implemented. See the feature list for details.
A comprehensive CLI tool to migrate React applications from version 16 to newer versions (17, 18, 19) with full TypeScript support and automated code transformations.
ReactDOM.render
to createRoot
(React 18+)React.PropTypes
to prop-types
packageuseState
(basic cases)--create-backup
)The React Migration CLI is designed to automate the complex process of upgrading React applications from version 16 to newer versions. Here's what it handles:
ReactDOM.render → createRoot Migration
ReactDOM.render()
to ReactDOM.createRoot().render()
Lifecycle Method Updates
componentWillMount
→ componentDidMount
componentWillReceiveProps
→ componentDidUpdate
componentWillUpdate
→ componentDidUpdate
PropTypes Modernization
React.PropTypes
to prop-types
packageBasic Class to Functional Component Conversion
useState
(advanced patterns are not yet supported)Package Version Updates
Configuration File Updates
Migration Analysis
Detailed Reporting
--create-backup
)# Install globally
npm install -g kdreact-migrate
# Or use npx
npx kdreact-migrate [version] [path]
# Migrate to React 18 (default)
react-migrate
# Migrate to specific version
react-migrate 17
react-migrate 18
react-migrate 19
# Migrate specific project
react-migrate 18 /path/to/react-project
# Dry run (show changes without applying)
react-migrate 18 --dry-run
# Verbose output
react-migrate 18 --verbose
# Skip dependency updates
react-migrate 18 --skip-deps
# Only update dependencies
react-migrate 18 --deps-only
# Check compatibility without migrating
react-migrate check 18
# Analyze specific package
react-migrate analyze-package react-router-dom
# Generate migration report only
react-migrate report 18
# Validate current setup
react-migrate validate
Pre-Migration Analysis
# Run compatibility check
react-migrate check 18
# Generate detailed report
react-migrate report 18
Dry Run (Recommended)
# Preview changes without applying
react-migrate 18 --dry-run
Full Migration
# Run actual migration
react-migrate 18
Post-Migration Verification
# Validate migration results
react-migrate validate
# Run tests to ensure functionality
npm test
# Clone the repository
git clone https://github.com/imkuldeepahlawat/kdreact-migrate.git
cd kdreact-migrate
# Install dependencies
npm install
# Build the project
npm run build
# Development
npm run dev # Watch mode
npm run build # Build TypeScript
npm run clean # Clean build artifacts
# Testing
npm test # Run tests
npm run test:watch # Watch mode tests
npm run test:coverage # Tests with coverage
# Code Quality
npm run lint # ESLint
npm run lint:fix # Fix linting issues
npm run type-check # TypeScript type checking
npm run format # Prettier formatting
npm run format:check # Check formatting
# Documentation
npm run docs # Generate TypeDoc
npm run docs:serve # Serve documentation
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watch
The project includes comprehensive GitHub Actions workflows that can be tested locally using nektos/act:
# Install act
brew install act
# Test workflows locally
act workflow_dispatch -W .github/workflows/test-local.yml --container-architecture linux/amd64
See GITHUB_ACTIONS.md for detailed workflow documentation.
This project includes comprehensive CI/CD workflows:
All workflows are tested locally and ready for production use.
The tool supports migration of 40+ React-related packages including:
Backup Your Project
Review Dependencies
Test Current Setup
Manual Review Required
Performance Testing
Gradual Deployment
The project uses TypeScript with strict settings and comprehensive type checking.
ESLint is configured with TypeScript support and recommended rules.
Prettier ensures consistent code formatting across the project.
# Create a new release on GitHub
# The publish workflow will automatically:
# 1. Run quality checks
# 2. Format code
# 3. Publish to NPM
# 4. Create GitHub release
Documentation is automatically deployed to GitHub Pages on every push to main.
We welcome contributions! Please see our Contributing Guide for detailed information on:
# Run all quality checks
npm test && npm run lint && npm run type-check && npm run format:check && npm run build
Copy .env.example
to .env
and configure the environment variables for your development setup:
cp .env.example .env
# Edit .env with your preferred settings
MIT License - see LICENSE file for details.
Complete TypeScript Migration - All original JavaScript functionality restored
Comprehensive Testing - 40 tests with 100% coverage
GitHub Actions - Full CI/CD pipeline with local testing
Documentation - Complete API documentation with TypeDoc
Code Quality - ESLint, Prettier, TypeScript strict mode
Production Ready - Ready for NPM publishing and deployment
Based on testing with various React applications:
Note: Success rates may vary based on project complexity and custom implementations.