Skip to content

Conversation

@jorge-cab
Copy link
Contributor

@jorge-cab jorge-cab commented Oct 27, 2025

Summary:
Revamped the derivationCache graph.

This fixes a bunch of bugs where sometimes we fail to track from which props/state we derived values from.

Also, it is more intuitive and allows us to easily implement a Data Flow Tree.

We can print this tree which gives insight on how the data is derived and should facilitate error resolution in complicated components

Test Plan:
Added a test case where we were failing to track derivations. Also updated the test cases with the new error containing the data flow tree


Stack created with Sapling. Best reviewed with ReviewStack.

@meta-cla meta-cla bot added the CLA Signed label Oct 27, 2025
@jorge-cab jorge-cab force-pushed the pr34995 branch 4 times, most recently from 4af24bf to 308f659 Compare October 28, 2025 00:07
@jorge-cab jorge-cab changed the title [compiler] Add data flow tree to compiler error for no-deriving-state-in-effects [compiler] Fix false negatives and add data flow tree to compiler error for no-deriving-state-in-effects Oct 28, 2025
@jorge-cab jorge-cab force-pushed the pr34995 branch 2 times, most recently from 6e29244 to b762183 Compare October 28, 2025 01:22
@jorge-cab jorge-cab marked this pull request as ready for review October 28, 2025 01:24
@jorge-cab jorge-cab force-pushed the pr34995 branch 2 times, most recently from 1e2ab32 to 4a8789c Compare October 28, 2025 20:33
This setState call is setting a derived value that depends on the following reactive sources:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait Prop: [props] missing here seems like a bug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

…d instead update typeOfValue and fix infinite loops

Summary:
With this we are now comparing a snapshot of the derivationCache with the new changes every time we are done recording the derivations happening in the HIR.

We have to do this after recording everything since we still do some mutations on the cache when recording mutations.



Test Plan:
Test the following in playground:
```
// @validateNoDerivedComputationsInEffects_exp

function Component({ value }) {
  const [checked, setChecked] = useState('');

  useEffect(() => {
    setChecked(value === '' ? [] : value.split(','));
  }, [value]);

  return (
    <div>{checked}</div>
  )
}
```

This no longer causes an infinite loop.

Added a test case in the next PR in the stack
…or for `no-deriving-state-in-effects`

Summary:
Revamped the derivationCache graph.

This fixes a bunch of bugs where sometimes we fail to track from which props/state we derived values from.

Also, it is more intuitive and allows us to easily implement a Data Flow Tree.

We can print this tree which gives insight on how the data is derived and should facilitate error resolution in complicated components

Test Plan:
Added a test case where we were failing to track derivations. Also updated the test cases with the new error containing the data flow tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants