penumbra-zone / web

Apache License 2.0
10 stars 7 forks source link

Stop using loader functions, part 1 #1306

Closed jessepinho closed 1 week ago

jessepinho commented 1 week ago

This PR goes through a bunch of routes where we're using react-router loaders, and replaces loader functionality with ZQuery. Note that this means some assumptions have changed about when data is available. react-router loaders wait to render their route components until data has loaded, which means your component can assume the data is already present. Since we're now effectively loading data from useEffect() (by way of ZQuery), we can't assume that data is present just because a component is rendered. So you'll see some instances of code that accounts for undefined where we didn't previously have to.

One of the benefits of this change is that route changes are instant. There's no lag time between when you click on a link to a route, and when the route changes, like there was before when route changes were blocked by loaders.

Before (note the delayed route changes after I click)

https://github.com/penumbra-zone/web/assets/1121544/7fbb50a0-4acf-4789-b0d2-51d99c49fcef

After (note the instant route changes after I click)

https://github.com/penumbra-zone/web/assets/1121544/22a7dba1-3ae8-4fef-a753-5e3f8479669e

In this PR

Future PRs

Relates to #1243

changeset-bot[bot] commented 1 week ago

🦋 Changeset detected

Latest commit: 8601886edcce858931e92d05830659e7b910b6e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | --------------------- | ----- | | @penumbra-zone/zquery | Patch | | minifront | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

TalDerei commented 1 week ago

good to merge barring the resolution of conflicts ~

TalDerei commented 1 week ago

@jessepinho I still had a few questions I left as comments I was hoping you could answer, selfishly for my own benefit?