Skip to content

Example of using commitLocalUpdate with relay-nextjs #72

Answered by rrdelaney
p-null asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @p-null! Relay exports a hook to get the environment used in RelayEnvironmentProvider: useRelayEnvironment. Passing this to commitLocalUpdate should work:

function Ticker() {
  const env = useRelayEnvironment();
  useEffect(() => {
    const tickInterval = setInterval(() => {
      commitLocalUpdate(env, (store) => {
        // ...
      });
    }, 3000);

   return () => clearInterval(tickInterval);
  }, [env]);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rrdelaney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants