question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

local state not working

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
lifeiscontentcommented, Apr 28, 2021

@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!

1reaction
lifeiscontentcommented, Apr 27, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found