pacificclimate / weather-anomaly-tool

0 stars 0 forks source link

Mediate backend requests with React Query #106

Closed rod-glover closed 1 month ago

rod-glover commented 2 months ago

Title. This change made it simple to make several simplifications and improvements, including fixing #103 and #105 .

Resolves #102 Resolves #103 Resolves #105

rod-glover commented 2 months ago

@Nospamas , it's a minor point, but I wonder if the appropriate flag from useQuery for "in progress" is isPending rather than isLoading. There's a subtle difference between them. Any thoughts?

Nospamas commented 2 months ago

@Nospamas , it's a minor point, but I wonder if the appropriate flag from useQuery for "in progress" is isPending rather than isLoading. There's a subtle difference between them. Any thoughts?

I think you're right. There is also some information on an alternative ("data first") pattern here on the blog guide. Overall though it does sound like we should be using isPending for initial load queries. I'll have to go back and review station data portal when the opportunity arises.

In the context of config, this might not be too relevant as I notice in line with how I did it on MDP, you're setting the staleTime: Infinity property on the config object, so it should very rarely be re-fetched. As such isLoading will be the same as isPending for it (I think, the only load will be the first one). My other queries on MDP however won't share that, they have stale timeouts mostly set to 24 hours (I should really apply that as default!).

rod-glover commented 1 month ago

One other warning popped up when I was testing. Couldn't identify its location though (and searching for defaultProps revealed nothing in the project)

Warning: M: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.
M@https://super-space-goggles-4j6pqqgw37gww-3000.app.github.dev/static/js/bundle.js:116475:13

Worth fixing if possible, but otherwise ignore.

Not caused by this code; must be in a dependency.