facebook / facebook/relay

LocalQueryRenderer uses useLayoutEffect which warns during server-rendering

Open
#2,854 4 comments 1 reaction 0 assignees View on GitHub
enhancement wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I'm using Next.js with Relay. We used `fetchQuery` to run a query in getInitialProps, which populates the store.

Until now we've used `relay-query-lookup-renderer` with `STORE_ONLY` during render to make sure all the subscriptions are set up correctly, but this breaks with 6.0. I tried switching to `LocalQueryRenderer`, which works, but warns on the server during render due to its use of `useLayoutEffect`.

Contributor guide

Open the contributing guide

Research direction

Start by locating LocalQueryRenderer and the useLayoutEffect that produces the server-rendering warning, then compare its behavior with relay-query-lookup-renderer in STORE_ONLY mode. Reproduce the warning with the fetchQuery/getInitialProps setup described in the issue. Done means server rendering no longer warns while the required subscriptions remain set up correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.