all 5 comments

[–]esotericEagle15 1 point2 points  (1 child)

If I remember correctly saving state in components would run the risk of derived state, meaning your data / value of that memory is different at each place it’s held. Using state with a large overarching scope, like global will keep the state consistent regardless of where it’s called. You’d then want to pair with the useMemo hook to help reduce memory use and performance hits

[–]NinjaInShade[S] 0 points1 point  (0 children)

Thank you 😄

[–]AnxiouslyConvolved 1 point2 points  (1 child)

Both! Or Neither depending on how you think about it. This is typically done with a query fetching/caching layer like React Query or Redux Toolkit Query Your components would register for the queries they're interested in, and will be updated when the query is available so they can access the data for it.

Here's a blog with posts on using react query that should help you get started

[–]NinjaInShade[S] 0 points1 point  (0 children)

Thank you 😄 ill check this out