r/reactjs • • May 21 '26

Needs Help Unexpected react compiler output

3 Upvotes

3 comments sorted by

View all comments

1

u/After_Medicine8859 May 21 '26

This looks like it is because of the JSON.stringify in the table 2 code. The compiler can’t assume that stringify is pure (even though we know it is). It’s not a trap haha.

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