Skip to content

17.Hooks相关源码调试

js
function App() {
  const [name, setName] = useState('yangyitao');
  const [age, setAge] = useState(30)
  const [address, setAddress] = useState('china')
  const [job, setJob] = useState('front end developer')
  function changeState(){
    setName('yangyitao plus')
    setAge(35)
    setAddress('sichuan')
    setJob('full stack developer')
  }

  return <div>
    {'name: ' + name}<br/> { 'age ' + age}<br/> {'address: ' + address}<br/> {'job: ' + job}<br/>
    <button onClick={changeState}>change states</button>
  </div>
}

ReactDOM.render(<App/>, document.getElementById('root'));

基于 VitePress 构建