hook use effect with hooks
import React, { useState, useEffect } from 'react'; function Example() { const [count, setCount] = useState(0); useEffect(() => { document.title = `Você clicou ${count} vezes`; }); return ( <div> <p>Você clicou {count} vezes</p> <button onClick={() => setCount(count + 1)}> Clique aqui </button> </div> ); }
Source: pt-br.reactjs.org