diff --git a/src/index.js b/src/index.js index bff95123..5d5f0f8f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,2 +1,47 @@ /* eslint-disable react/react-in-jsx-scope, react/jsx-filename-extension */ /* @jsx createElement */ + +function createElement(tagName, props, ...children) { + const element = document.createElement(tagName); + + Object.entries(props || {}).forEach(([key, value]) => { + element[key.toLowerCase()] = value; + }); + children.flat().forEach((child) => { + if (child instanceof Node) { + element.appendChild(child); + return; + } + element.appendChild(document.createTextNode(child)); + }); + + return element; +} + +function render({ count }) { + function handleClick() { + render({ + count: count + 1, + }); + } + + const element = ( +
+ {[1, 2, 3, 4, 5, 6, 7, 8, 9].map((i) => ( + + ))} +
++ {count} +
+