Skip to content
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

How to clear all reactive variables states? #11224

Closed
konrazem opened this issue Sep 17, 2023 · 3 comments
Closed

How to clear all reactive variables states? #11224

konrazem opened this issue Sep 17, 2023 · 3 comments
Labels

Comments

@konrazem
Copy link

konrazem commented Sep 17, 2023

Is there any method, hook that I can use to reset all reactive variables states in the react application? I understand I cannot use client.resetStore or clearStore as reactive variable is "representing local state outside of the Apollo Client cache".

I can do

const resetAllReactiveVariables = () => {
  myReactiveVariableA({});
  myReactiveVariableB(null);
  myReactiveVariableC(false);

... 52 more

however it is not elegant solution and I am not sure if this will make 55 rerenders?

I am looking something like

const { rv } = useApolloClient()

const resetAllReactiveVariables = () => rv.clear()

Where reactive variable state is saved if not in cache?

@konrazem konrazem changed the title [client][reactive-variable] How to clear all reactive variables states? How to clear all reactive variables states? Sep 17, 2023
@bignimbus
Copy link
Contributor

Hi @konrazem 👋🏻 thanks for the question! The functionality you're describing with reactive variables is not currently available in Apollo Client. You could try using local resolvers to do the same thing, however. Does that help?

@bignimbus bignimbus added the 🏓 awaiting-contributor-response requires input from a contributor label Sep 20, 2023
@konrazem
Copy link
Author

Yes, thank you for your answer. I understand there is no such option and I have to do it one by one.

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
For general questions, we recommend using StackOverflow or our discord server.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants