useEffect(() => {
document.title = `you click ${count} times`
},[])
- useEffect函数里面写内容,相当于在componentDidMount和componentDidUpdate生命周期函数中写内容
- useEffect第二个参数写[],相当于componentDidMount生命周期函数
- [count]:只监听count发生改变的时候,才会触发 componentDidUpdate生命周期函数
- useEffect里面返回函数,在返回的函数中写内容相当于在componentDidMount与componentDidUpdate和componentWillUnmount生命周期函数中写内容