> For the complete documentation index, see [llms.txt](https://jonathan-zhang.gitbook.io/react-steppitguide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jonathan-zhang.gitbook.io/react-steppitguide/react-ji-chu-zhi-shi/han-shu-zu-jian/react-hooks/useeffect.md).

# useEffect

* 每次渲染之后都会执行

```javascript
import React, { userState, useEffect } from 'react'

const ViewUserName = () => {
  const [userName, setUserName ] = userState('');
  useEffect(() => {
    document.title = `用户-${userName}`;
  })
  return (
    <>
      <input value={userName} onChange={(val)=> { setUserName(val) }} />
    <>
  )
}
```
