useLazyQuery returns old data
See original GitHub issueWhy 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:
- Created 3 years ago
- Reactions:6
- Comments:7 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should no longer be an issue in
@apollo/client@latest
- let us know otherwise, thanks!Same problem here, shouldn’t this be an open issue?