News for hackers. Stuff that matters.
Re:Thinking in React Hooks by ng12 on Thursday December 12, 2019 @12:09PM (#21773740)
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) that take the non-JSX approach further. Although honestly, I don't recommend it. JSX is really great even it seems a little unfamiliar.

There are no comments on this comment yet.