const {useState}=React
function App(){
const [title,setTitle]=useState("this is a title")
const [content,setContent]=useState("this is a content")
return (
<div>
<h1>{title}</h1>
<button onClick={()=>setTitle("这是标题")}>set title</button>
<p>{content}</p>
<button onClick={()=>setContent("这是内容")}>set content</button>
</div>
)
}
const root=ReactDOM.createRoot(document.querySelector('#app'));
root.render(<App/>)
运行结果