Expand description
Optimizes the code for running in an SSR environment.
Assumes that setState will not be called during render during initial mount, which allows inlining useState/useReducer.
Optimizations:
- Inline useState/useReducer
- Remove effects (useEffect, useLayoutEffect, useInsertionEffect)
- Remove event handlers (functions that call setState or startTransition)
- Remove known event handler props and ref props from builtin JSX tags
- Inline useEffectEvent to its argument
Ported from TypeScript src/Optimization/OptimizeForSSR.ts.
Functionsยง
- optimize_
for_ ssr - Optimizes a function for SSR by inlining state hooks, removing effects, removing event handlers, and stripping known event handler / ref JSX props.