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",