1.hook沒有this
2.useState const [count, setCount] = useState(0); 一個初始值 一個是更新值
3.useEffect 方法 在類組件中想當於 componentDidMount 和componentDidUpdate以及componentWillUnmount 三個的結合(與調用順序有關)
4.使用規則:
Hook 使用了 JavaScript 的閉包機制,
使用規則: 1.只有最頂層使用hook 不能在循環,條件調用hook.
2.只能再react函數中使用hook,不能再普通的js函數中調用hook
5.自定義hook 必須以use 開頭