← Trail· Lesson 4 of 8
Effects with useEffect
Sync with the outside world after 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)} />;
}