local state not working
See original GitHub issueI followed the tutorial at https://www.apollographql.com/docs/tutorial/local-state/
Whenever I include the local state as in export const LAUNCH_TILE_DATA = gql' fragment LaunchTile on Launch { id isInCart @client isBooked rocket { id name } mission { name missionPatch } } ';
then the Query only returns {} . If I remove isInCart @client, then the query is successful and gives the launch information. What’s wrong with the local state?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (6 by maintainers)
Top Results From Across the Web
React local state does not update after onclick - Stack Overflow
When I press the all-in-one button. This local state does not change. It displays a false value by default.
Read more >How To Use and Not Use State - React Training
Here's the quick facts on useReducer vs useState : They both make local state; You can use either one. Some will argue that...
Read more >Why React doesn't update state immediately - LogRocket Blog
When developing React applications, you may have noticed that state updates don't immediately reflect new values after being changed.
Read more >Hooks FAQ - React
They let you use state and other React features without writing a class. This page answers some of the frequently asked questions about...
Read more >React state not updating immediately? - Daggala
It might seems like the state update isn't updating or lagging behind. ... If not, here are three solutions to this problems.
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
@hwillson Thanks for asking. with-apollo requires you to have a root query for each individual page. getDataFromTree allows you to not have to expose a root query. There are also issues with the ergonomics of next.js e.g. if you have a query that depends on query parameters, the react context for the next.js router I don’t believe is populated so using getDataFromTree is pointless in that case.
Also, it would be nice to see how to handle the case that I mentioned, e.g. theirs an error via SSR in graphql but then cleared out due to the data of the query being cleared out because the Apollo cache doesn’t store errors in it. But in production environments it’s very important to not drop errors. There is currently not a defined practice on how to handle these kinds of cases. Feel free to message me directly if you want more details. Happy to chat!
Based on my experience with Next.js and Apollo Client, Both technologies are good, but they’re not good together due to how they are expected to be used. But maybe I just don’t understand something and if possible, it would be great to have some of this confusion uncovered.