Skip to content

Why doesn't @xstate/react useMachine rerender with change in subactor? #4633

Discussion options

You must be logged in to vote

Right now, you can use the inspect API to do this. In plain XState, it's this:

const actor = createActor(machine, {
  inspect: (inspEvent) => {
    // something happened
    localStorage.setItem('state', actor.getPersistedSnapshot())
// ...

With React:

const [/* ... */] = useMachine(machine, {
  inspect: (inspEvent) => {
    // same logic
// ...

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@brandonchinn178
Comment options

@Andarist
Comment options

@brandonchinn178
Comment options

@davidkpiano
Comment options

Answer selected by brandonchinn178
@brandonchinn178
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants