score:2

Ok, there're multiple reasons:

  1. Your side effect won't always be meaningful or even runnable in server-side render, and in SSR componentDidMount hook won't be called, your teardown logic won't be run either
  2. It may trigger unintended setState which is addressed in this answer
  3. In some circumstance component will be constructed, but won't be mounted or will be mounted later, and call side effect in their constructor is meaningless

Related Query

More Query from same tag