-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ApolloClient 3: Cannot update a component from inside the function body of a different component. #6188
Comments
This is similar to the error I get - I believe it's just a different string in React 16.13.1:
@hwillson any chance you could fix this here as well? |
Is this still an issue for people using the latest |
Currently on |
This issue was indeed fixed for me in |
Tried on |
For some reason |
I am getting this when using I am on I have a
A
And in a child component when a button is pressed the reactive component is updated, which updates my query via a local client only field:
Then my data is updated via the other reactive var
This pattern for pagination (i.e. using reactive hooks + client schema fields) appears to cause this error to occur. |
@coler-j I've just encountered the same issue, and fixed it by adding the reactive var mutation in an effect. In your case, that would be: export default function App() {
const { data } = useQuery(. .......... )
useEffect(() => {
currentDataVar(data);
}, [data]);
return (<>
<SomeComponentToRenderData />
<SomeChildComponent />
</>
)
} |
@coler-j |
@asaadawey I have not circled back but I anticipate that this #6188 (comment) comment should fix it. Although this is not in the docs, effects that impact state should typically be wrapped in |
@coler-j |
Should i re-open this issue if it's still a problem? |
@Banou26 wrapping the apollo code inside a |
Any update on this issue? Since I started using pagination I have run into this problem. I tried reworking to put the code in side of useEffect instead, but it doesn't seem to make a difference. |
@alexistbell I'm not sure if it's exactly the same issue, but I submitted this PR which might fix it: #9801. This change is available in version |
Thanks @dylanwulf , that is making the error go away, which is helpful because it looks like I have a different issue I need to track down that isn't related, so now I can focus on that. |
related to apollographql/react-apollo#3863
Intended outcome:
useQuery
should not throw unintentional state changes warning.Actual outcome:
Error thrown:
Warning: Cannot update a component from inside the function body of a different component.
How to reproduce the issue:
probably the same as apollographql/react-apollo#3863 (comment)
Versions
"@apollo/client": "^3.0.0-beta.44"
The text was updated successfully, but these errors were encountered: