DEV Community

Murali venkat
Murali venkat

Posted on

Component Re-renders

Hello everyone,
I am new to this community and I am facing an issue that a component re-renders every time when I navigate to other menus, The following is the order of component
Login component -> Home Component -> Child components.
The other components are children of a home component in the router module. Whenever I go to other menus the home component renders every time and the constructor and ngoninit is calling every time. Can anyone know why this is occurring?

Thanks.

Top comments (2)

Collapse
 
renancferro profile image
Renan Ferro

Hey how are you?!

This depends a lot on how your component is structured! Some interesting points to look at would be:

  • Is your component modularized?!
  • Did you declare the component outside the ?!

I also advise you to add a new tag, which would be discuss!

Collapse
 
tqbit profile image
tq-bit • Edited

Hi Murali.

Perhaps you can add a bit more context to your question.

  • What framework are you using (I assume it's angular)?
  • What libraries are you using (e.g. Redux, Mobx for state management?)
  • Provide an example of your code