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

281
Visualizações
Why React needs to check if the node is root before rendering?

I am learning about React internals from a talk by Paul O’Shannessy "Building React from scratch"

In "7:29" before explaining how rendering process work, he added these few lines of code which i really couldn't understand

const ROOT_KEY = 'dlthmRootId";
const instancesByRootId = {};
let rootId = 1;

function isRooot(node) {
 if(node.dataset[RootKEY]) {
   return true
 }
 else {
   return false
 }
}

He said that we need to make sure that no roots conflict!

I can't understand this part, what roots to conflict, is this related to server side rendering? or rendering to multiple roots instead of one root node in the app?

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

0

React app will be initialized in DOM with the code below.

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(<App />, document.getElementById('root'));

What it does is render React component into an element in DOM with the id 'root'.

Therefore, if there is any case where the root element will be duplicated or two React apps attempt to manipulate one single root element, that would be called root 'conflicts'.

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