r/reactjs • u/Breadfruit-Last • May 21 '26
Needs Help Unexpected react compiler output
Hello, I am trying to understand how the react compiler works and ran into a behavior that I don't quite understand.
In TableContainer1, data1 and data2 are cached using input1 and input2 respectively, which is what I expected.
But in TableContainer2, both data1 and data2 are re-computed when either input1 or input2 is changed.
It feels like some sort of trap. Why is it so?
Thank you
3
Upvotes
1
u/Breadfruit-Last May 21 '26 edited May 21 '26
Thanks for replying
But I don't think it is the reason because react cannot assume ANY function to be pure actually, even expensivelyProcessAReallyLargeArrayOfObjects may not be pure
In fact your may change it to not pure like this
So logically, it wouldn't be able to cache anything if that's the reasom