Goodbye, useEffect: David Khourshid - YouTube

2022-06-09

https://youtu.be/HPoC-k7Rxwo

Reactathon 2022 の発表動画。
まだ自分の中でまとまりきっていないので、とりあえずポイントとなりそうな部分をピックアップ。

useEffect()
is not for Effects
https://youtu.be/HPoC-k7Rxwo?t=131

What is useEffect() for?
Syncronization.
https://youtu.be/HPoC-k7Rxwo?t=603

動画内に出てくる @dan_abramov さんのツイートはこれ。
https://twitter.com/dan_abramov/status/1501737272999301121

Can event handlers have side effects?
Absolutely! Event handlers are the best place for side effects.
https://beta.reactjs.org/learn/responding-to-events#can-event-handlers-have-side-effects
https://youtu.be/HPoC-k7Rxwo?t=707

Where do action effects go?
Event handlers.
In state transitions.
...which happen to be executed at the same time as event handler.
https://youtu.be/HPoC-k7Rxwo?t=1070

Effects are state management.
Don't put side-effects aside.
https://youtu.be/HPoC-k7Rxwo?t=1486

Summary

useEffect is for synchronization (not for effects と口頭で補足していた)
State transitions trigger effects
Effects go in event handler
Render-as-you-fetch (suspense)
Model effects with state machine
https://youtu.be/HPoC-k7Rxwo?t=1507

Source: React Status Issue 292: June 8, 2022