Files
react/compiler/crates/react_hermes_parser/tests/fixtures/immutable-hooks.js
2024-04-02 16:49:31 -07:00

10 lines
320 B
JavaScript

// @enableAssumeHooksFollowRulesOfReact true
function Component(props) {
const x = {};
// In enableAssumeHooksFollowRulesOfReact mode hooks freeze their inputs and return frozen values
const y = useFoo(x);
// Thus both x and y are frozen here, and x can be independently memoized
bar(x, y);
return [x, y];
}