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

244
Vistas
TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'. Did i do anything wrong?

I'm trying to make a h1 with JavaScript and it gives me this error:

TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.

The code:

function append(child) {
  document.body.appendChild(child);
};

const title = React.createElement(
  'h1',
  null,
  'Hello World',
);
append(title);
console.log(header);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

React elements are not DOM elements, so you can't use them with appendChild.

You'll want to either use the DOM directly or use React, but usually not both (or at least, typically in a React project the amount of direct DOM manipulation you do is fairly minimal).

Here's that code using the DOM (no React):

function append(child) {
    document.body.appendChild(child);
}

const title = document.createElement("h1");
title.textContent = "Hello world";
append(title);
console.log(title); // Changed `header` to `title`, you have no `header` element in the code

Doing the same with React, you wouldn't typically have an append function like yours. You'd have a single call to ReactDOM.render in the entire project (usually) that mounted your top-level React component in a DOM element; everything else would be rendered by React as part of handling the component logic.

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