Actions always trigger useEffect when in dependencies
See original GitHub issueI 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?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Why does useEffect trigger on mount for Context API ... - Reddit
The dependency array tells useEffect when it should run again. It will always run at least once, when the component mounts. That's why...
Read more >The last guide to the useEffect Hook you'll ever need
Dependencies are array items provided as the optional second argument of the useEffect call. Array values must be from the component scope ...
Read more >Triggering useEffect only certain conditions - Stack Overflow
Say I have useEffect with two dependencies (from GraphQL query): result.data and result.loading . I want useEffect to run if result.data changes ...
Read more >How to manage the useEffect dependency array like a pro?
The useEffect hook allows you to perform side effects in a functional component. There is a dependency array to control when the effect...
Read more >4 Ways to useEffect() - DEV Community
To call a function conditionally, specify the list of dependencies. And the rule of thumb is to always add those dependencies that you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
should fixed with 4.1.2 https://codesandbox.io/s/little-state-machine-demo-forked-90vmo?file=/src/form.js:556-609
thanks, should be fixed in the next patch.