Actions always trigger useEffect when in dependencies
rpk-red opened this issue · comments
I have useEffects in my codebase that have little-state-machine actions as dependencies, everything worked fine until I update little-state-machine from version "3.1.2"
to 4.1.0
. Now Actions call every time useEffect and re-render my components.
Also tried with TS demo sample from your docs, only added this effect :
useEffect(() => { console.log("called every time"); actions.updateFirstLastName({ yourDetails: { firstname: "testFirst", lastname: "testLast" } }); }, [actions]);
in Form.tsx
file. And got same result.
Not sure what to do, can someone help?
I don't think it's the correct behaviour: https://codesandbox.io/s/little-state-machine-demo-forked-90vmo?file=/src/form.js
@bluebill1049 > I don't think it's the correct behaviour: https://codesandbox.io/s/little-state-machine-demo-forked-90vmo?file=/src/form.js
You have to call some action inside useEffect also. For example:
actions.updateFirstLastName(...);
thanks, should be fixed in the next patch.
@bluebill1049 can you tell me when will next patch be released? Or if you can tell me what is highest package version that has no such bag?
can you try with the latest?
@bluebill1049 I updated to version 4.1.1 and it still has the same issue.
should fixed with 4.1.2 https://codesandbox.io/s/little-state-machine-demo-forked-90vmo?file=/src/form.js:556-609
It works now! Thank you for fast response. :)