useQuery causes warning in strict mode
See original GitHub issueWhen I wrap my app in <React.StrictMode />, some of my components cause the following warning:
Warning:` Can't perform a React state update on an unmounted component. This is a
no-op, but it indicates a memory leak in your application. To fix, cancel all
subscriptions and asynchronous tasks in a useEffect cleanup function.
These warning disappear outside of Strict Mode and in production builds (which turn off the StrictMode behavior). The components in question don’t set state or use useEffect. They all use useQuery however.
The warnings disappear when I remove useQuery, i.e. by replacing this:
const { data: { preference = {} } = {} } = useQuery(PREFERENCE) with an example response, like this:
const { data: { preference = {} } = {} } = {
data: {
preference: {
id: 'dc1d27d7-c5fe-4de6-97c5-9db2bfaa7cd8',
toc: false
}
}
}
and leaving the rest of the component unchanged.
I am using "@apollo/client": "^3.3.2"
This issue was originally reposted in react-apollo repo: https://github.com/apollographql/react-apollo/issues/3635
Issue Analytics
- State:
- Created 3 years ago
- Reactions:23
- Comments:17 (4 by maintainers)
Top Results From Across the Web
React-Apollo - Query - renderProp: React warning: Can't ...
I'm using "Query" from "react-apollo" and my application returns me this error. I think I am understanding the problem: my application is trying ......
Read more >Strict Mode - React
StrictMode is a tool for highlighting potential problems in an application. Like Fragment , StrictMode does not render any visible UI. It activates...
Read more >Upgrading to React 18 · Step-by-step guide - Felix Mokross
I assume this to be caused by the new rendering mechanism of React 18. ... const root = createRoot(container); root.render( <StrictMode> …
Read more >urql/CHANGELOG.md - UNPKG
18, - Avoid React v16.13.0's "Warning: Cannot update a component" by ... 26, - ⚠️ Fix more concurrent-mode and strict-mode edge cases and...
Read more >Optimistic UIs with React, Apollo Client and TypeScript (Part III)
If sending a message within a messages client causes the UI to update ... Notice how there are twenty-one messages on the optimistic...
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
@dchenk Can you try the beta release (
npm i @apollo/client@beta
)? It might be fixed on there.@DennieMello This week!