Can I use Multiple useEffects in a single Component?

Can I use Multiple useEffects in a single Component?

Using the useEffect hook we can inform the react that we need some data after component render. It can handle any side effect in your component data.

React allow us to use multiple hooks in a single component. For example, we need multiple states in a single component so we can easily utilize multiple useState hooks in one particular component.


  • const [data,setData]= useState(24);
  • const [data1,setData]= useState(25);


same like as useState, we can also utilize multiple useEffects in one functional component. Its depend on case study where you need to implement multiple useEffects. 


Source:

https://reactjs.org/docs/hooks-effect.html#tip-use-multiple-effects-to-separate-concerns

Saad Ahmed

Senior Mobile Developer @Direct | Ex Team Lead @Cinnova | MERN | MEAN | Full Stack Developer

4 å¹´

Yes you can

Haseeb Ahmed

Full Stack Developer | Building scalable solutions for complex business problems

4 å¹´

Yes ofcourse !

要查看或添加评论,请登录

Azeem Aleem的更多文章

  • Stop Using Inline Styles in React js

    Stop Using Inline Styles in React js

    Always avoid passing inline Styles to any react components. It's a little tiny thing that causes a huge problem in our…

    28 条评论
  • React + Leaflet in web Applications

    React + Leaflet in web Applications

    We use a lot of mobile apps which are using map services. Same like google map, Uber, Careem and Bykea mobile…

    2 条评论
  • Difference Between Git & Github

    Difference Between Git & Github

    Git Git is a version control system for tracking changes in computer files/Your local system. But what is the version…

    1 条评论
  • Interview-Based Concept (CONST)

    Interview-Based Concept (CONST)

    Concept of const is a little bit tricky which you should understand if you are a javascript developer. When anybody…

    2 条评论
  • How does JS Hoisting work?

    How does JS Hoisting work?

    Variable Hoisting is a by the default behaviour of javascript to compile the code in a specific manner. We mostly…

  • REST API vs Web API

    REST API vs Web API

    What is the difference between API and REST API? Not all APIs are REST, but all REST services are APIs So let's start a…

    4 条评论
  • Pure and Impure Functions in React/JS

    Pure and Impure Functions in React/JS

    Pure Functions A Pure function is a function that does not modify any external variable. And the Impure function…

    8 条评论
  • What is Async/await in React

    What is Async/await in React

    "Await" only works inside the Async functions. As you know that asynchronous function tasks are never dependent on each…

    7 条评论

社区洞察

其他会员也浏览了