Skip to content
This repository has been archived by the owner on Dec 12, 2023. It is now read-only.

Assign with no transition has "ssign" or "" as target #23

Closed
yoav-lavi opened this issue Apr 30, 2021 · 2 comments · Fixed by #25
Closed

Assign with no transition has "ssign" or "" as target #23

yoav-lavi opened this issue Apr 30, 2021 · 2 comments · Fixed by #25
Labels
bug Something isn't working

Comments

@yoav-lavi
Copy link

Hey,
Noticed that if you try to make a transition containing only an assign action, it adds a "ssign" target if no other state is defined, or "" if another state is defined (whereas I would expect no target in such a case)

state initial {
  TEST => assign(someValue)
}

The resulting code is

import { createMachine, assign } from 'xstate';

export default createMachine({
  states: {
    initial: {
      on: {
        TEST: {
          target: 'ssign',
          actions: [
            assign({
              someValue: (context, event) => event.data
            })
          ]
        }
      }
    }
  }
});

And when doing the following:

state initial {
  TEST => assign(someValue)
}

state other {}

The resulting code is

import { createMachine, assign } from 'xstate';

export default createMachine({
  states: {
    initial: {
      on: {
        TEST: {
          target: '',
          actions: [
            assign({
              someValue: (context, event) => event.data
            })
          ]
        }
      }
    },
    other: {

    }
  }
});

I'm aware that Lucy is in alpha and issues are to be expected, just wanted to give you a heads up :)

Good luck!

@yoav-lavi yoav-lavi changed the title Assign with no transition has "ssign" as target Assign with no transition has "ssign" or "" as target Apr 30, 2021
@matthewp
Copy link
Collaborator

Thanks! Yes this is indeed a bug. I'm curious if we should require a target state at the end of a transition or should we implicitly transition back into itself?

@matthewp matthewp added the bug Something isn't working label May 1, 2021
matthewp pushed a commit that referenced this issue May 1, 2021
matthewp added a commit that referenced this issue May 1, 2021
Fixes #23

Co-authored-by: Matthew Phillips <matthew@phillipsoft.com>
@matthewp
Copy link
Collaborator

matthewp commented May 1, 2021

This is fixed in 0.1.5, thanks a lot for bringing the issue to my attention!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants