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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to update Valtio state from redux devtools? #260

Closed
AshConnolly opened this issue Oct 21, 2021 · 5 comments 路 Fixed by #261
Closed

Is it possible to update Valtio state from redux devtools? #260

AshConnolly opened this issue Oct 21, 2021 · 5 comments 路 Fixed by #261
Assignees

Comments

@AshConnolly
Copy link

AshConnolly commented Oct 21, 2021

Hi there! 馃憢 馃槃

I'm using Valtio with redux devtools so I can view my app state. Is there is a way to update state from the dev tools?
With redux you would dispatch an action to update state. Is something like this possible with Valtio?

Thanks again for all the amazing state tools! 馃殌

Edit:
I found this repo - https://github.com/oslabs-beta/deValtio . I tried it but it didn't work for me, presumably it's in development. A Valtio chrome extension would be amazing!

Additionally I often wonder if people are hesitant to use state libraries that don't clearly show state in devtools. Like with context you can see and modify context state in the react devtools, which is nice.

I know valtio and zustand avoid any need for context which is great, but perhaps there could be an optional way of wrapping your app in some sort of valtio state-helper. So we could see and modify valtio state from the react devtools? 馃
I've not cracked open the valtio src so no idea if this is possible, just a thought! 馃槃

@AshConnolly AshConnolly changed the title How to update Valtio state from redux devtools? Is it possible to update Valtio state from redux devtools? Oct 21, 2021
@dai-shi
Copy link
Member

dai-shi commented Oct 21, 2021

Thanks for opening the issue. AFAIK, "Jump" should work at least. Have you tried it?
Can you dispatch an arbitrary action with redux?

@AshConnolly
Copy link
Author

AshConnolly commented Oct 21, 2021

Hi @dai-shi!
Thanks for the help! 馃槃
Oh yeh I can see jump, but I believe that can only be used to jump back to a previous state? Not to set a new state with a passed value?

Can you dispatch an arbitrary action with redux?

I tried this:
Screenshot 2021-10-21 at 15 29 31
but it didn't work.
Usually I would use the action names defined in my redux setup, but not sure how to find the correct action name that maps to valtio 馃

@dai-shi
Copy link
Member

dai-shi commented Oct 21, 2021

Can you try this:

{
  type: "JUMP_TO_STATE",
  state: {
    count: 9,
    text: 'hey'
  }
}

@AshConnolly
Copy link
Author

That didn't seem to do anything I'm afraid!
Stackblitz here if it helps! - https://stackblitz.com/edit/react-ts-durn2c?file=index.tsx
Thanks again!

@Aslemammad Aslemammad self-assigned this Oct 22, 2021
@Aslemammad
Copy link
Member

#261

@dai-shi dai-shi linked a pull request Oct 23, 2021 that will close this issue
dai-shi added a commit that referenced this issue Nov 9, 2021
* feat: assign JSON.parse in dispatch

* chore: remove devtools from example

* fix: remove isSupportedObject

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* Update src/vanilla.ts

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* fix: handle non-supported values

* Update src/utils/devtools.ts

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* Update src/utils/devtools.ts

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* Update src/utils/devtools.ts

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* Update src/utils/devtools.ts

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>

* empty commit

* empty commit

Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
Co-authored-by: daishi <daishi@axlight.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants