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

It doesn't transition to other state #15

Closed
aislanmaia opened this issue Feb 28, 2019 · 4 comments
Closed

It doesn't transition to other state #15

aislanmaia opened this issue Feb 28, 2019 · 4 comments
Assignees

Comments

@aislanmaia
Copy link

aislanmaia commented Feb 28, 2019

As xstate 4.3.3 and using use-machine 1.1.0, the state doesn't get transitioned to others states at all.
Just tested with the following tutorial (updating it to use use-machine and just plain functions components through React Hooks) and tested with the example in the README of this repo.

It seems just get dispatched and captured the events, but doesn't transitions.

@carloslfu carloslfu reopened this Mar 1, 2019
@carloslfu carloslfu self-assigned this Mar 1, 2019
@carloslfu
Copy link
Owner

Hi, @aislanmaia. Thanks for reporting. Did you resolve it? If not please provide a code example or a sandbox (in codesandbox.com) and, I´ll review it.

@aislanmaia
Copy link
Author

aislanmaia commented Mar 1, 2019

Hello @carloslfu. Thanks for replying. I don't know what happened, maybe I misunderstood some concepts, but I checked that the statechart was something locked into just 2 states chains, and the others wasn't get triggered. Anyways I have resolved it. But now, I'm getting confused because I'm losing my state through the hot-reloads from create-react-app.

My question is how can I use the use-machine states to survive the reloads after saving. Maybe I should open another issue to this question?? I have uploaded a repo with the reproducible issue.
Here: example project

@carloslfu
Copy link
Owner

You can do it this way easily if you have only one instance of the statechart, if not it becomes trickier but not impossible. You have to create a wrapper around useMachine for saving each XState instance and swapping it on hot-reload. I'm gonna create an issue for creating such wrapper.

@aislanmaia
Copy link
Author

Confirmed working like a charm following the instructions in the link above.

For others in this thread, my index.js starting from example project is as below:

/* code above omitted */

const render = (Component) => ReactDOM.render(
  <AppProvider>
    <App />
   </AppProvider>
   , document.getElementById("root")
);

render(App)

if (module.hot) {
  module.hot.accept('./App', () => {
    const NextApp = require('./App').default
    render(NextApp)
  })
}

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

No branches or pull requests

2 participants