/
aksem62
/
react-latest
Обзор
Документация
Войти
/
aksem62
/
react-latest
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
customReact/customreact.js
26 строк
881 B
aksem62
make basic things
07 янв 2024, 20:57
07 янв 2024, 20:57
7b2c3b4
Код
Авторство
О чём код?
function customRender(reactElement, container) { /* const domElement = document.createElement(reactElement.type) domElement.innerHTML = reactElement.children; domElement.setAttribute('href', reactElement.props.href) domElement.setAttribute('target', reactElement.props.target) container.appendChild(domElement) */ const domElement = document.createElement(reactElement.type); domElement.innerHTML = reactElement.children; for (const prop in reactElement.props) { if (prop === "children") continue; domElement.setAttribute(prop, reactElement.props[prop]); } container.appendChild(domElement); } const reactElement = { type: "a", props: { href: "https://google.com", target: "_blank", }, children: "Click me to visit google", }; const mainContainer = document.querySelector("#root"); customRender(reactElement, mainContainer);