Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

151
Vistas
Performance and memory difference between re-mounting vs setting display = "none"

I have a single page application written in React. The app has multiple pages which can be displayed when the user clicks the tabs on the Nav Bar. So there are 2 possible designs:

  1. Mount the pages 1 at a time; unmount and remount whenever the user switches between pages via clicking the tab.

  2. Mount all of the pages simultaneously and only display the page selected while setting the rest to display = "none".

Questions:

  1. Which is better in terms of speed performance.
  2. Which is better in terms of memory performance.
  3. Which is standard practice?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I believe this has nothing to do with best practice or performance. It all depends on what you are trying to achieve.

Keep in mind the following:

Mounting / remounting always resets the component's state and reruns the useEffect hooks (this is something really really useful in react's world). This means that if you use for example a stepper and you move between steps, let's say you fill some forms, then going front and back, your components will lose their previous state and your forms will be emptied (because they are mount again).

But, if you you use display = none the state of your components is persistent and your forms will be filled with the previous values. (Obviously you can achieve the same behavior with the first approach but you will need some effort to do so, an effort that will save you some time in a later point)

I do not say the one is better than the other, but there are some serious considerations you have to know before choosing one over the other

(don't use display=none unless you are into some serious css tricks)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda