Loading...
const visible = useMemo(
() => todos.filter((t) => !t.done),
[todos]
);
const onToggle = useCallback((id) => toggle(id), [toggle]);const visible = todos.filter((t) => !t.done);
const onToggle = (id) => toggle(id);With the compiler on, plain code is memoized automatically, so new code skips manual useMemo and useCallback.
useMemo, useCallback or memo() by default when the compiler is enabled.No, it works on existing code that follows the Rules of React. Components it cannot safely optimize are skipped and keep working as before.
Yes, add the 'use no memo' directive at the top of the component or file to skip it temporarily.
No, it runs at build time as a compiler plugin and outputs JavaScript that uses React's normal APIs.