← Ruta· Lección 4 de 8
Efectos con useEffect
Sincronizar con el mundo externo después del render.
TODO i18n: Full body translation pending. Title and description are localized; the body below remains in Portuguese for now.
useEffect roda depois do paint. Use para título do documento, subscriptions e timers — não para calcular UI.
import { useEffect, useState } from 'react';
function App() {
const [titulo, setTitulo] = useState('React');
useEffect(() => {
document.title = titulo;
}, [titulo]);
return <input value={titulo} onChange={(e) => setTitulo(e.target.value)} />;
}