Closed kirillku closed 6 years ago
Thank you very much for opening this issue, @kirillku.
I confirm that, at the moment, react-automata
is setting the state on each transition
call (even when the machine state is not changed).
I'm planning to implement a few optimisations soon.
However, this shouldn't be an issue as your components should be able to render multiple times with no side-effects.
In any case, if you want to prevent the component to re-render when the state doesn't change, you can extends PureComponent
(instead of Component
).
I hope this helps.
Hey @kirillku, v4 is out and now the component renders only when the machine state actually changes.
First of all, thanks for a great lib. I started to use
react-automata
in my project and found one issue. When there is an transition to impossible state, the transition doesn't happen, but component still gets rerendered. As for me, in this case nothing should happen. I checked the code, looks like you dosetState
on wrapper component even if a transition was not possible and this results in rerendering wrapped component.Here is a codesandbox with example: https://codesandbox.io/s/9lz8jq68ro