Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing React codebases, migrating to React Hooks, or upgrading to latest React versions.
.claude/skills/microck-react-modernization/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 97% | 0% |
| case-01 | ✗→✓ | ▲ Improved | 195% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 67% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 175% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 136% | 0% |
Master React version upgrades, class to hooks migration, concurrent features adoption, and codemods for automated transformation.
Breaking Changes by Version:
React 17:
React 18:
javascript// Before: Class component class Counter extends React.Component { constructor(props) { super(props); this.state = { count: 0, name: '' }; } increment = () => { this.setState({ count: this.state.count + 1 }); } render() { return ( <div> <p>Count: {this.state.count}</p> <button onClick={this.increment}>Increment</button> </div> ); } } // After: Functional component with hooks function Counter() { const [count, setCount] = useState(0); const [name, setName] = useState(''); const increment = () => { setCount(count + 1); }; return ( <div> <p>Count: {count}</p> <button onClick={increment}>Increment</button> </div> ); }
javascript// Before: Lifecycle methods class DataFetcher extends React.Component { state = { data: null, loading: true }; componentDidMount() { this.fetchData(); } componentDidUpdate(prevProps) { if (prevProps.id !== this.props.id) { this.fetchData(); } } componentWillUnmount() { this.cancelRequest(); } fetchData = async () => { const data = await fetch(`/api/${this.props.id}`); this.setState({ data, loading: false }); }; cancelRequest = () => { // Cleanup }; render() { if (this.state.loading) return <div>Loading...</div>; return <div>{this.state.data}</div>; } } // After: useEffect hook function DataFetcher({ id }) { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { let cancelled = false; const fetchData = async () => { try { const response = await fetch(`/api/${id}`); const result = await response.json(); if (!cancelled) { setData(result); setLoading(false); } } catch (error) { if (!cancelled) { console.error(error); } } }; fetchData(); // Cleanup function return () => { cancelled = true; }; }, [id]); // Re-run when id changes if (loading) return <div>Loading...</div>; return <div>{data}</div>; }
javascript// Before: Context consumer and HOC const ThemeContext = React.createContext(); class ThemedButton extends React.Component { static contextType = ThemeContext; render() { return ( <button style={{ background: this.context.theme }}> {this.props.children} </button> ); } } // After: useContext hook function ThemedButton({ children }) { const { theme } = useContext(ThemeContext); return ( <button style={{ background: theme }}> {children} </button> ); } // Before: HOC for data fetching function withUser(Component) { return class extends React.Component { state = { user: null }; componentDidMount() { fetchUser().then(user => this.setState({ user })); } render() { return <Component {...this.props} user={this.state.user} />; } }; } // After: Custom hook function useUser() { const [user, setUser] = useState(null); useEffect(() => { fetchUser().then(setUser); }, []); return user; } function UserProfile() { const user = useUser(); if (!user) return <div>Loading...</div>; return <div>{user.name}</div>; }
javascript// Before: React 17 import ReactDOM from 'react-dom'; ReactDOM.render(<App />, document.getElementById('root')); // After: React 18 import { createRoot } from 'react-dom/client'; const root = createRoot(document.getElementById('root')); root.render(<App />);
javascript// React 18: All updates are batched function handleClick() { setCount(c => c + 1); setFlag(f => !f); // Only one re-render (batched) } // Even in async: setTimeout(() => { setCount(c => c + 1); setFlag(f => !f); // Still batched in React 18! }, 1000); // Opt out if needed import { flushSync } from 'react-dom'; flushSync(() => { setCount(c => c + 1); }); // Re-render happens here setFlag(f => !f); // Another re-render
javascriptimport { useState, useTransition } from 'react'; function SearchResults() { const [query, setQuery] = useState(''); const [results, setResults] = useState([]); const [isPending, startTransition] = useTransition(); const handleChange = (e) => { // Urgent: Update input immediately setQuery(e.target.value); // Non-urgent: Update results (can be interrupted) startTransition(() => { setResults(searchResults(e.target.value)); }); }; return ( <> <input value={query} onChange={handleChange} /> {isPending && <Spinner />} <Results data={results} /> </> ); }
javascriptimport { Suspense } from 'react'; // Resource-based data fetching (with React 18) const resource = fetchProfileData(); function ProfilePage() { return ( <Suspense fallback={<Loading />}> <ProfileDetails /> <Suspense fallback={<Loading />}> <ProfileTimeline /> </Suspense> </Suspense> ); } function ProfileDetails() { // This will suspend if data not ready const user = resource.user.read(); return <h1>{user.name}</h1>; } function ProfileTimeline() { const posts = resource.posts.read(); return <Timeline posts={posts} />; }
bash# Install jscodeshift npm install -g jscodeshift # React 16.9 codemod (rename unsafe lifecycle methods) npx react-codeshift <transform> <path> # Example: Rename UNSAFE_ methods npx react-codeshift --parser=tsx \ --transform=react-codeshift/transforms/rename-unsafe-lifecycles.js \ src/ # Update to new JSX Transform (React 17+) npx react-codeshift --parser=tsx \ --transform=react-codeshift/transforms/new-jsx-transform.js \ src/ # Class to Hooks (third-party) npx codemod react/hooks/convert-class-to-function src/
javascript// custom-codemod.js module.exports = function(file, api) { const j = api.jscodeshift; const root = j(file.source); // Find setState calls root.find(j.CallExpression, { callee: { type: 'MemberExpression', property: { name: 'setState' } } }).forEach(path => { // Transform to useState // ... transformation logic }); return root.toSource(); }; // Run: jscodeshift -t custom-codemod.js src/
javascriptfunction ExpensiveComponent({ items, filter }) { // Memoize expensive calculation const filteredItems = useMemo(() => { return items.filter(item => item.category === filter); }, [items, filter]); // Memoize callback to prevent child re-renders const handleClick = useCallback((id) => { console.log('Clicked:', id); }, []); // No dependencies, never changes return ( <List items={filteredItems} onClick={handleClick} /> ); } // Child component with memo const List = React.memo(({ items, onClick }) => { return items.map(item => ( <Item key={item.id} item={item} onClick={onClick} /> )); });
javascriptimport { lazy, Suspense } from 'react'; // Lazy load components const Dashboard = lazy(() => import('./Dashboard')); const Settings = lazy(() => import('./Settings')); function App() { return ( <Suspense fallback={<Loading />}> <Routes> <Route path="/dashboard" element={<Dashboard />} /> <Route path="/settings" element={<Settings />} /> </Routes> </Suspense> ); }
typescript// Before: JavaScript function Button({ onClick, children }) { return <button onClick={onClick}>{children}</button>; } // After: TypeScript interface ButtonProps { onClick: () => void; children: React.ReactNode; } function Button({ onClick, children }: ButtonProps) { return <button onClick={onClick}>{children}</button>; } // Generic components interface ListProps<T> { items: T[]; renderItem: (item: T) => React.ReactNode; } function List<T>({ items, renderItem }: ListProps<T>) { return <>{items.map(renderItem)}</>; }
markdown### Pre-Migration - [ ] Update dependencies incrementally (not all at once) - [ ] Review breaking changes in release notes - [ ] Set up testing suite - [ ] Create feature branch ### Class → Hooks Migration - [ ] Identify class components to migrate - [ ] Start with leaf components (no children) - [ ] Convert state to useState - [ ] Convert lifecycle to useEffect - [ ] Convert context to useContext - [ ] Extract custom hooks - [ ] Test thoroughly ### React 18 Upgrade - [ ] Update to React 17 first (if needed) - [ ] Update react and react-dom to 18 - [ ] Update @types/react if using TypeScript - [ ] Change to createRoot API - [ ] Test with StrictMode (double invocation) - [ ] Address concurrent rendering issues - [ ] Adopt Suspense/Transitions where beneficial ### Performance - [ ] Identify performance bottlenecks - [ ] Add React.memo where appropriate - [ ] Use useMemo/useCallback for expensive operations - [ ] Implement code splitting - [ ] Optimize re-renders ### Testing - [ ] Update test utilities (React Testing Library) - [ ] Test with React 18 features - [ ] Check for warnings in console - [ ] Performance testing
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-02 | fail→pass | 14,407 | 11,941 | -17% | 1 | 1 | 0% | 2,635 | 5,187 | +97% | 0 | 0 | — |
case-01 | fail→pass | 9,023 | 9,207 | +2% | 1 | 1 | 0% | 1,729 | 5,098 | +195% | 0 | 0 | — |
case-03 | fail→fail | 11,834 | 10,282 | -13% | 1 | 1 | 0% | 2,314 | 5,428 | +135% | 0 | 0 | — |
case-04 | pass→pass | 9,266 | 5,921 | -36% | 1 | 1 | 0% | 1,520 | 4,175 | +175% | 0 | 0 | — |
case-05 | pass→pass | 11,038 | 12,465 | +13% | 1 | 1 | 0% | 2,482 | 5,861 | +136% | 0 | 0 | — |
case-06 | fail→pass | 11,398 | 2,106 | -82% | 1 | 1 | 0% | 2,101 | 3,506 | +67% | 0 | 0 | — |
case-07 | pass→pass | 7,887 | 7,717 | -2% | 1 | 1 | 0% | 1,681 | 4,629 | +175% | 0 | 0 | — |
case-08 | pass→pass | 11,901 | 12,468 | +5% | 1 | 1 | 0% | 2,068 | 5,457 | +164% | 0 | 0 | — |
case-09 | pass→pass | 6,238 | 5,972 | -4% | 1 | 1 | 0% | 1,212 | 4,260 | +251% | 0 | 0 | — |
case-10 | pass→pass | 9,099 | 10,702 | +18% | 1 | 1 | 0% | 1,703 | 4,604 | +170% | 0 | 0 | — |
case-11 | pass→pass | 14,968 | 20,712 | +38% | 1 | 1 | 0% | 2,881 | 5,600 | +94% | 0 | 0 | — |
case-12 | pass→pass | 8,150 | 8,115 | -0% | 1 | 1 | 0% | 1,421 | 4,521 | +218% | 0 | 0 | — |
case-13 | pass→pass | 6,029 | 5,899 | -2% | 1 | 1 | 0% | 1,119 | 4,183 | +274% | 0 | 0 | — |
case-14 | pass→pass | 14,455 | 10,892 | -25% | 1 | 1 | 0% | 2,383 | 4,967 | +108% | 0 | 0 | — |
case-15 | pass→pass | 8,726 | 4,177 | -52% | 1 | 1 | 0% | 1,385 | 3,710 | +168% | 0 | 0 | — |
case-16 | pass→pass | 9,220 | 6,485 | -30% | 1 | 1 | 0% | 1,722 | 4,318 | +151% | 0 | 0 | — |
case-17 | pass→pass | 13,529 | 11,689 | -14% | 1 | 1 | 0% | 2,667 | 5,282 | +98% | 0 | 0 | — |
case-18 | pass→pass | 4,260 | 3,504 | -18% | 1 | 1 | 0% | 698 | 3,670 | +426% | 0 | 0 | — |
case-19 | pass→pass | 13,453 | 11,552 | -14% | 1 | 1 | 0% | 2,154 | 5,253 | +144% | 0 | 0 | — |
case-20 | fail→fail | 7,043 | 3,990 | -43% | 1 | 1 | 0% | 1,260 | 3,869 | +207% | 0 | 0 | — |
case-21 | pass→pass | 10,553 | 7,771 | -26% | 1 | 1 | 0% | 1,919 | 4,543 | +137% | 0 | 0 | — |
case-22 | pass→pass | 11,443 | 10,275 | -10% | 1 | 1 | 0% | 2,248 | 5,167 | +130% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.