Replies: 1 comment 1 reply
-
Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
In a project, I am using React. To explain the issue in short - I created a machine and a service. I used that machine in a hook and created context, provider and consumer and exported them all (so I can use the event handlers and data from that service locally and globally in my React application). Here's the sandbox and here's the explanation -
The structure of my state machine looks like this:
states.yaml
file contains a YAML representation of the state machine.options.js
file simply exports an object withactions
,activities
,services
, andguards
as keys and contains the implementations of the state machine.index.js
creates the variables required for sharing the service across different components.This is how
index.js
looks like:Above machine can be imported by folder and used anywhere and it works like it should. Issue arises in this one component (named
Sketch
) which takes the objects containing event handlers of the invoked machine as its prop and then uses it in a function, which in itself is return value of a higher order function to be used later by P5.js and create a canvas out of the return value. Usage is shown below -And following is the implementation of
Sketch
-Calling
service.send
inside the children of Sketch (which is a higher order) function doesn't update the service.service.send
does return the next state of the app, but doesn't modify the service itself. Thestate.value
remains same for the service which was passed in.Beta Was this translation helpful? Give feedback.
All reactions