📜  如何在功能组件中使用componentdidmount - Javascript代码示例

📅  最后修改于: 2022-03-11 15:03:18.756000             🧑  作者: Mango

代码示例2
useEffect(() => {
  window.addEventListener('mousemove', () => {});

  // returned function will be called on component unmount 
  return () => {
    window.removeEventListener('mousemove', () => {})
  }
}, [])