Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

181
Visualizações
Why is react re-rendering/updating all components in the page

I have a react application which uses Material UI v5. I do not have any styling and am using the default TextField component to test the rendering issue. In my page, I have only a Typography, Breadcrumb, IconButton and TextField. To replicate the issue, I have put one controlled TextField and about six other uncontrolled TextFields. When I start writing on the controlled TextField, all the components inside page starts re-rendering. And if I start typing a lot/faster, it sometimes freezes or takes a while (like 500-1000ms) to render the text inside the TextField. Basically it freezes for a second or half.

Here is a replicated demo of what I have. My real project is also using create-react-app. I have the same thing in my react app and it renders everything. Here is a link to a snap taken. I used the react developer tools profilers "Highlight updates when components render" option.

My Environment details:

System:
OS: Windows 10 10.0.19043
Binaries:
Node: 14.17.4 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD
npm: 7.20.3 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.19041.1023.0), Chromium (93.0.961.52)
npmPackages:
@emotion/react: ^11.4.1 => 11.4.1
@emotion/styled: ^11.3.0 => 11.3.0
@mui/core: 5.0.0-alpha.47
@mui/icons-material: ^5.0.0 => 5.0.0
@mui/lab: ^5.0.0-alpha.47 => 5.0.0-alpha.47
@mui/material: ^5.0.0 => 5.0.0
@mui/private-theming: 5.0.0
@mui/styled-engine: 5.0.0
@mui/styled-engine-sc: ^5.0.0 => 5.0.0
@mui/styles: ^5.0.0 => 5.0.0
@mui/system: 5.0.0
@mui/types: 7.0.0
@mui/utils: 5.0.0
@types/react: 17.0.22
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
styled-components: ^5.3.1 => 5.3.1

Is this the react behavior? Can I stop re-rendering/updating of all components when one component updates its state?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

React components are made using a rule called decomposition. Each component can have a father and a child (if not alone) and can be modeled as shown in this picture. React component tree

When the state is updated in the parent component, to update the screen, this component is rendered and also all the child components are rendered in it.

if you want to prevent this behavior in a class component you need to use shouldComponentUpdate you can read its doc in here and if you want to handle it in a functional component you can use useMemo hook, and you can read its doc in here

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda