Goodbye, useEffect: David Khourshid

Created time
Nov 25, 2022 10:57 AM
Summary
useEffect should be used in transition, not as a side effect handler
Progress
Done
Category
Programming
Source
Youtube

Why it is bad?

Strict mode

First of all, since React v18, strict mode is implemented. It will mount you component twice to ensure solidity of your code, so useEffect will be called twice.

It is too imperative:

notion image

What is it good for?

It is good for synchronization

notion image

Event listeners

notion image

Where should effects go?

notion image
notion image
notion image
notion image

Notes

Fetching data

notion image
notion image

Effects

notion image

Conclusion

notion image