2 ms·
Do you mean JSX? Here you go: import {createElement as h} from "react" const Counter = () => { const [count, setCount] = React.useState(0)
by ng12 7y ago
Do you mean JSX? Here you go:
import {createElement as h} from "react"
const Counter = () => {
const [count, setCount] = React.useState(0)
return h("div", {},
h("p", {}, `You have clicked the button ${count} times`),
h("button", {onClick: () => setCount(count => count + 1)}, "Increment")
)
}
There are additionally libs like hyperscript (https://github.com/mlmorg/react-hyperscript https://github.com/mlmorg/react-hyperscript) that take the non-JSX approach further. Although honestly, I don't recommend it. JSX is really great even it seems a little unfamiliar.