- Upgrading to modern APIs, including React 18+
- Automatically memoizing components
- Converting to modern hooks
- Standardizing prop types
- Organizing components into individual files
Converting Class Components to Functions
Here’s how to convert React class components to functional components:Migrating to Modern Hooks
Convert legacy patterns to modern React hooks:Standardizing Props
Inferring Props from Usage
Add proper prop types and TypeScript interfaces based on how props are used:Extracting Inline Props
Convert inline prop type definitions to separate type declarations:Extracting prop types makes them reusable and easier to maintain. It also
improves code readability by separating type definitions from component logic.
Updating Fragment Syntax
Modernize React Fragment syntax:Organizing Components into Individual Files
A common modernization task is splitting files with multiple components into a more maintainable structure where each component has its own file. This is especially useful when modernizing legacy React codebases that might have grown organically.- Find files containing multiple React components
- Create a new directory structure based on the original file
- Move each non-default exported component to its own file
- Preserve imports and dependencies automatically
- Keep default exports in their original location
The
strategy="add_back_edge" parameter ensures that any components that were
previously co-located can still import each other without circular
dependencies. Learn more about moving
code here.