diff --git a/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.expect.md b/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.expect.md index 61e283f619..b84ed09282 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.expect.md @@ -6,7 +6,7 @@ function Component(props) { const [value, setValue] = useState(null); // NOTE: this lambda does not capture any mutable values (only the state setter) // and thus should be treated as readonly - const onChange = (e) => setX((value) => value + e.target.value); + const onChange = (e) => setValue((value) => value + e.target.value); useOtherHook(); @@ -22,9 +22,9 @@ function Component(props) { ```javascript function Component(props) { - useState(null); + const setValue = useState(null)[1]; - const onChange = (e) => setX((value) => value + e.target.value); + const onChange = (e) => setValue((value) => value + e.target.value); useOtherHook(); diff --git a/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.js b/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.js index 0bdca05afd..bd10465c74 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.js +++ b/compiler/forget/src/__tests__/fixtures/hir/inadvertent-mutability-readonly-lambda.js @@ -2,7 +2,7 @@ function Component(props) { const [value, setValue] = useState(null); // NOTE: this lambda does not capture any mutable values (only the state setter) // and thus should be treated as readonly - const onChange = (e) => setX((value) => value + e.target.value); + const onChange = (e) => setValue((value) => value + e.target.value); useOtherHook();