Skip to content

[Question] How to update context without changing state? #87

Description

@DaveWelling

Often pieces of state will be needed for decisions in the effect methods. Would you recommend keeping these instead in an external useState, or is there some way to pass these in via events (without changing state).

for instance, in xstate you can do something like this:

{
   states: {
      start: {
         on: {
            readCountChange: {
               actions: [assign((context, event)=>{ return { readsExist: event.readCount > 0}})]
            }
         }
      ...
    }
}

And then use that readsExist later in a condition to decide if some other event should be allowed to make a state change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions