Accepted answer

When you use scripts, React is exposed on the window object as React, you also use a version of React which doesn't have hooks(hooks were released in 16.8)

Update your scripts to(you might want to use the development scripts for better error messages)

<script src=""></script>
<script src=""></script>

If you want to access useState destructure it from React or use React.useState

Also, use onChange instead of onClick for input change events as well as using the text value from state as the value of the input

<script type="text/babel">
  const { useState } = React

  const App = (props) => { 
    const [text, setText] = useState('hello');

    return (
        <input type="text" value={text} onChange={(e) => setText(} />

  const rootElement = document.getElementById('root')
  ReactDOM.render(<App />, rootElement)

Related Query

More Query from same tag