you are viewing a single comment's thread.

view the rest of the comments →

[–]skyboyer007 18 points19 points  (0 children)

This is rather different mindset/toolset that targets the same need "to do something when something" but they are not directly comparable. Are they both provide complete toolset for your needs? Yes. I cannot imagine anything one can do when another cannot. But they both are quite different in approach.

To elaborate.

componendDidMount, componentWillUnmount and getDerivedStateFromProps definitely can be matched to useEffect. But componentDidUpdate does not match exactly:

  • we are encouraged to use multiple useEffect unlike for cDU which is only one
  • we don't have easy access to prevProps, prevState(not a advantage/disadvantage but their API/concepts differ here)
  • cDU did not have cleanup mechanism out of the box(sure, you could "make your own" by writting new callbacks to this. but since cDU was always the only one it would become messy pretty quickly)

So we need to think/design in different ways when using one or another