carloslfu / xstate-router

XState Router. Add routes to your XState machine.
MIT License
112 stars 16 forks source link

route-changed event triggered after xstate.init on the same route #26

Open joernroeder opened 4 years ago

joernroeder commented 4 years ago

I'm noticing that route-changed events are triggered even if the machine gets initialized on that particular route. This leads to duplicate actions on state entry and invocations of services at the target route.

I've isolated the behavior in this sandbox: https://codesandbox.io/s/xstate-router-forked-fyff8

my suggestion is to omit the route-changed event and not trigger it if the route did not change or the previous event was xstate.init.

carloslfu commented 4 years ago

Thanks, @joernroeder.

zchbndcc9 commented 3 years ago

Any updates on this?

redbar0n commented 1 year ago

bump