Should I use one or many useEffect in component?

后端 未结 2 974
野的像风
野的像风 2020-12-02 05:53

I have some side effects to apply and want to know how to organize them:

  • as a single useEffect
  • or several useEffects

What\'s better in

2条回答
  •  盖世英雄少女心
    2020-12-02 06:30

    You should use multiple effects to separate concerns as suggested by reactjs.org https://reactjs.org/docs/hooks-effect.html#tip-use-multiple-effects-to-separate-concerns

提交回复
热议问题