/react-master:react-optimize ComponentName or path/to/Component.tsxfrom react-master
Analyzes a React component for performance bottlenecks and applies optimizations like memoization, stable callbacks, code splitting, and video/media element best practices.
Ships in react-master. Installing the plugin adds it to Claude Code.
Analyze and optimize a React component for better performance.
$ARGUMENTS - Component name or file path to optimizeAnalyze and optimize the specified React component:
Performance Analysis
$ARGUMENTSCommon Issues to Check
Inline object/function creation in JSX
Missing React.memo on pure components
Missing useMemo for expensive calculations
Missing useCallback for callbacks passed to children
Large component bundles (code splitting opportunities)
Missing keys or unstable keys in lists
Video/media element re-render issues (see below)
Video/Media Element Checks:
<video> elements using unstable keys (e.g., array index) causing decoder churn on re-renderuseRef to control play/pause/seek imperativelyReact.memo on video player components, causing remount on parent re-rendersonTimeUpdate={() => ...}) --- use useCallback for onPlay, onPause, onEnded, onTimeUpdate, onLoadedMetadatauseMemoplaysInline attribute for iOS Safari compatibilityOptimization Techniques
Report Format
// Before - new object every render
<Child style={{ color: 'red' }} />
// After - stable reference
const style = useMemo(() => ({ color: 'red' }), []);
<Child style={style} />
// Before - new function every render
<List onItemClick={(id) => handleClick(id)} />
// After - stable callback
const handleItemClick = useCallback((id: string) => {
handleClick(id);
}, [handleClick]);
<List onItemClick={handleItemClick} />
// Before - computed every render
const sortedItems = items.sort((a, b) => a.name.localeCompare(b.name));
// After - memoized
const sortedItems = useMemo(
() => [...items].sort((a, b) => a.name.localeCompare(b.name)),
[items]
);
// Before
function ExpensiveList({ items }: Props) { ... }
// After
const ExpensiveList = memo(function ExpensiveList({ items }: Props) { ... });
// Before - imported directly
import HeavyEditor from './HeavyEditor';
// After - lazy loaded
const HeavyEditor = lazy(() => import('./HeavyEditor'));
function App() {
return (
<Suspense fallback={<Loading />}>
<HeavyEditor />
</Suspense>
);
}
// Before - renders all items
{items.map(item => <Item key={item.id} {...item} />)}
// After - virtualized
import { FixedSizeList } from 'react-window';
<FixedSizeList height={400} itemCount={items.length} itemSize={50}>
{({ index, style }) => (
<Item style={style} {...items[index]} />
)}
</FixedSizeList>
// Before - blocks UI
setSearchResults(results);
// After - non-blocking
startTransition(() => {
setSearchResults(results);
});
After analysis, provide:
Issues Found
Optimized Code
Changes Made
Additional Recommendations
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
npx claudepluginhub josiahsiegel/claude-plugin-marketplace --plugin react-master4 commands in this plugin
Other plugins' commands for the same job