Answer the question
In order to leave comments, you need to log in
How to dynamically add a node to the DOM?
There is a file in which I create an element:
createTodo.js
import React from "react";
export default function createTodo() {
const todoInput = document.getElementById("input");
return (
<li>
<span className="todos_block-text">{todoInput.value}</span>
<span className="todos_block-trash"></span>
</li>
);
}
import createTodo from "./";
import React from "react";
export default function addTodo() {
document.querySelector('.todos_block').append(createTodo()); <----- Пример с append
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question