Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1992

RescriptRelay Query.use requires suspense wrapper

$
0
0

Query.use always suspend unless all data is already there, because it’s a lazy query - it initiates the data fetching on mount.

In Relay, using preloaded queries is best practice. Preloaded queries mean that the query itself is initiated somewhere else, before trying to render the component. This is typically in a route handler, click handler or similar. As close to the action that needs the query as possible.

I’ve built a dedicated router for RescriptRelay that makes it very simple to implement all of these best practices without sacrificing on DX or needing a lot of boilerplate: rescript-relay-router/packages/rescript-relay-router/README.md at main · zth/rescript-relay-router · GitHub. Using that will make it easy to use preloaded queries, do code splitting and fetch data+code in parallell, and so on. Recommended unless you’re already using a fw that does routing for you, I use it in almost all projects where I use RescriptRelay.


Viewing all articles
Browse latest Browse all 1992

Latest Images

Trending Articles



Latest Images