naimulcsx / progHours

A gamification-driven platform for problem solvers.
https://proghours.com
77 stars 2 forks source link

🚑️ Move suitable local states to global state #146

Closed naimulcsx closed 1 year ago

naimulcsx commented 2 years ago

The idea is to move user related states into a top level where we can expose these states via context API. We'll still be using react-query for data fetching at the top. But this ensures that the states that rarely changed or is only affected by the current user are living on the top of the tree. For example: user informations is rarely changed. On the other hand submissions is changed freqently, but we don't want to fetch submissions every time, we only fetch when the app is first rendered and then refetch it only when we absolutely need it (invalidate the query) + we can mutate the state locally (during deletion / updation etc). User informations and submissions are already in global state.