question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useLazyQuery returns old data

See original GitHub issue

Why that code is working improperly ? I change profileId and nothing happened, useLazyQuery is still returns the old data.

const [profile, setProfile] = useState<Profile>(null);
    const [getProfile, { loading, error, data }] = useLazyQuery<Data<'profile', Profile>, { id: string }>(PROFILE, {
      ssr: false,
    });

    useEffect(() => {
      getProfile({
        variables: { id: profileId },
      });
    }, [getProfile, profileId]);

    useEffect(() => {
      if (!loading && !error && data) {
        setProfile(data.profile);
      }
    }, [setProfile, data, loading, error]);

I am using:

    "@apollo/react-hooks": "^3.1.3",
    "apollo-client": "^2.6.8",

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
hwillsoncommented, Apr 30, 2021

This should no longer be an issue in @apollo/client@latest - let us know otherwise, thanks!

1reaction
OneTuskedMariocommented, Jul 20, 2022

Same problem here, shouldn’t this be an open issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

useLazyQuery returns old data - reactjs - Stack Overflow
I change profileId and nothing happened, useLazyQuery is still returns the old data. const [profile, setProfile] = useState<Profile>(null); ...
Read more >
[Solved]-useLazyQuery returns old data-Reactjs
Coding example for the question useLazyQuery returns old data-Reactjs.
Read more >
How to join useLazyQuery result with previous query result as ...
Im returning the data returned from the query as an array of components, but i need to return the data returned from the...
Read more >
Queries - Redux Toolkit
Returns the query state and accepts skip and selectFromResult . Reads the request status and cached data from the Redux store. useLazyQuery.
Read more >
useLazyLoadQuery - Relay
fetchPolicy : Determines if cached data should be used, ... If the fetchKey is different from the one used in the previous render, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found