facebook / facebook/relay

Request: useLazyloadQuery hook without suspense

Open
#4,079 10 comments 5 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I've migrated most of my team's codebase to useLazyloadQuery, using the Transitions API to make smooth transitions without suspending. However, one big pain point still is queries that don't need to block the page to load. For example, typeaheads or autocomplete options. In these cases, it makes more sense to just put a spinner inside the typeahead, a setup that doesn't lend itself to suspense + fallbacks as far as I can tell. Currently we use useQuery from relay-hooks in that case, but it causes confusion around when to use useQuery vs useLazyloadQuery.

The best workaround I have (other than resorting to another library which doesn't fully support react 18 strict mode) is to manually call fetchQuery and/or retain queries myself. That really feels like something the library should just be supporting if it's supporting something like useLazyloadQuery. I'm especially curious what Meta does internally in this case / what the recommendation is.

I tried searching for other Issues about this since I think they must exist, but couldn't find them, so apologies if there's another source of truth for this discussion.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.