<div id="app"></div>
const App = () => {
const [myName, setMyName] = React.useState('Ray');
return (
<div>
{ myName }
<button type="button" onClick={ () => setMyName('QQ 先生') }>更改名字</button>
</div>
)
}
const app = document.querySelector('#app');
const root = ReactDOM.createRoot(app);
root.render(<App />);
View Compiled