|
|
|
|
|
by jasonkillian
1269 days ago
|
|
Agreed, but it's a pretty big footgun because `useEffect` is often the seemingly easiest way to do the things you list. I've had similar conversations many times with coworkers before when they were using `useEffect` to keep a state value in sync with a prop. The officially-recommended alternative of manually storing and updating an extra piece of state containing the previous prop value is cumbersome and also had ways it can go wrong. So, since `useEffect` works well enough in most cases and is easier, often the code just sticks with that method. I'm not entirely sure what's really best all tradeoffs considered, but it definitely illustrates how rough edges often pop up in hook-based React. |
|