An open source codemod that safely removes useMemo and useCallback from React codebases — streamlining migration from React 18 to React 19 and the React Compiler
Published on npm • MIT Licensed • Zero AST dependencies
React 19 introduces the React Compiler, which handles memoization automatically. Codebases built on React 18 are littered with useMemo and useCallback calls that are now redundant. Manually removing them across thousands of files is tedious, error-prone, and risks breaking type annotations and import statements.
A two-step pipeline that first strips useMemo and useCallback calls using a character-by-character parser, then applies fixups to restore lost type annotations. Safe dry-run by default, idempotent, and handles nested generics, multi-line hooks, and complex edge cases that regex-based tools miss.
One command transforms your codebase — removing boilerplate while keeping everything type-safe
BEFORE
const value = useMemo(() => computeExpensiveValue(a, b), [a, b]);
const handler = useCallback((e) => doSomething(e), [doSomething]);
import { useMemo, useCallback, useState } from "react";AFTER
const value = computeExpensiveValue(a, b);
const handler = (e) => doSomething(e);
import { useState } from "react";A two-step pipeline with a character-by-character parser — no AST dependencies
npx react-compiler-unmemo ./my-app
Entry point — dry-run by default
Phase 1
Strip generic type parameters from hook calls
Phase 2
Remove hook calls, unwrap arrow functions, strip dep arrays
Phase 3
Clean unused useMemo/useCallback imports
Restore Types
Recover lost generic type annotations from stripped hooks
Infer Context
Heuristic type inference from surrounding code patterns
Clean, type-safe code
Ready for React Compiler — run tsc --noEmit to verify
Built for real-world codebases with complex patterns
No AST dependencies
Dry-run first, write when ready
Handles real-world patterns
React Compiler handles memoization automatically — removing hooks is optional but delivers real benefits
Less boilerplate, easier to read and maintain
React Compiler handles memoization automatically
Unused hook imports are removed entirely
Idempotent — won't touch already-processed files
# Preview changes (safe default — no files modified)npx react-compiler-unmemo ./my-react-app# Apply changes when readynpx react-compiler-unmemo ./my-react-app --write# Type-check your project afterwardnpx tsc --noEmit
Runtime dependencies beyond glob
Safe dry-run by default
Pipeline: remove hooks → fix types
"React Compiler works fine with existing manual memoization — it preserves and layers on top of it. Removing hooks is optional for cleanliness and readability, but not required for performance."— React Documentation
We build developer tools, codemods, and migration utilities — from open source packages to enterprise-grade toolchains.
Automated code transformations for framework upgrades
Open source and private packages for the JS ecosystem
Build systems, linters, and workflow automation
Custom tooling for large-scale codebases
Specializing in React tooling • Codemods • Open source • Developer experience