This repository has been archived by the owner on Jan 31, 2023. It is now read-only.
Tonyvanswet/ele 1346 UI panel rankingintro #26
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Started on ranking panel.
Realised that we need the translations and a solid way to shape the data.
I'd mostly like feedback around how we handle the fetching, caching and shaping of data.
Here's my logic around the process here:
Use react query solely for fetching and caching the data blobs returned by the apis, useGetState / useGetDetail will always mirror the last api response for the given time period we're interested in i.e. Month
Use the useMemo hook for calling functions that map that data from useGetState / useGetDetail based on the datetime we're interested in and the data shape that suits the function.
I tried loading all the logic into useQuery and yes it's possible to create more hooks to do the data shaping, I feel like we already have the benefit of react query (stale time etc) at the api level and useMemo makes things a bit more simple.