📌  相关文章
📜  如何使用 useEffect - Javascript 代码示例

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

代码示例1
import React, { useState, useEffect } from 'react';
function Example() {
  const [count, setCount] = useState(0);

  // Similar to componentDidMount and componentDidUpdate:  
  useEffect(() => {    
      // Update the document title using the browser API    
      document.title = `You clicked ${count} times`;  
  });
  
  return (
    

You clicked {count} times

); }