diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-multiple-calls-to-hoisted-callback-from-other-callback.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-multiple-calls-to-hoisted-callback-from-other-callback.expect.md new file mode 100644 index 0000000000..902b33880f --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-multiple-calls-to-hoisted-callback-from-other-callback.expect.md @@ -0,0 +1,46 @@ + +## Input + +```javascript +// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions +function Component(props) { + const [_state, setState] = useState(); + const a = () => { + return b(); + }; + const b = () => { + return ( + <> +
onClick(true)} /> +
onClick(false)} /> + + ); + }; + const onClick = (value) => { + setState(value); + }; + + return
{a()}
; +} + +export const FIXTURE_ENTRYPONT = { + fn: Component, + props: [{}], +}; + +``` + + +## Error + +``` + 9 | <> + 10 |
onClick(true)} /> +> 11 |
onClick(false)} /> + | ^^^^^^^ [ReactForget] Invariant: [InferReferenceEffects] Context variables are always mutable. (11:11) + 12 | + 13 | ); + 14 | }; +``` + + \ No newline at end of file diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-multiple-calls-to-hoisted-callback-from-other-callback.js b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-multiple-calls-to-hoisted-callback-from-other-callback.js new file mode 100644 index 0000000000..fa91f3b0f4 --- /dev/null +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.todo-multiple-calls-to-hoisted-callback-from-other-callback.js @@ -0,0 +1,25 @@ +// @enableAssumeHooksFollowRulesOfReact @enableTransitivelyFreezeFunctionExpressions +function Component(props) { + const [_state, setState] = useState(); + const a = () => { + return b(); + }; + const b = () => { + return ( + <> +
onClick(true)} /> +
onClick(false)} /> + + ); + }; + const onClick = (value) => { + setState(value); + }; + + return
{a()}
; +} + +export const FIXTURE_ENTRYPONT = { + fn: Component, + props: [{}], +};