Deferred value

지연 값

Show the latest value immediately while expensive UI briefly keeps an older value.

···
html
<div class="scene"><div class="search">search: <b id="query">R</b></div><div class="arrow">↓ deferred</div><div class="result"><div class="label">RESULTS FOR</div><strong id="deferred">R</strong><div class="cards"><i></i><i></i><i></i></div></div></div>
css
.scene{width:min(94vw,800px);height:min(86vh,320px);position:relative;overflow:hidden;display:flex;flex-direction:column;justify-content:space-between;border:1px solid var(--line);border-radius:14px;background:var(--surface);padding:clamp(9px,2.4vmin,20px);font:500 clamp(15px,4vmin,18px)/1.3 var(--font-sans,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif)}.scene b,.scene strong{font-weight:700}.label{color:var(--muted)}.code{font-family:ui-monospace,SFMono-Regular,Consolas,monospace}.pill{border:1px solid var(--line);border-radius:8px;padding:.4em .65em;background:var(--bg)}.active{border-color:var(--accent)!important;color:var(--accent)!important;background:color-mix(in srgb,var(--accent) 10%,var(--surface))!important}.search{border:1px solid var(--accent);border-radius:8px;padding:.6em;font-family:ui-monospace,monospace}.search b{color:var(--accent)}.arrow{text-align:center;color:var(--muted);margin:8px}.result{border:1px solid var(--line);border-radius:9px;padding:.6em;background:var(--bg)}.result strong{font:700 clamp(17px,5vmin,28px) ui-monospace,monospace}.cards{display:flex;gap:5px;margin-top:7px}.cards i{height:clamp(18px,5vmin,30px);flex:1;background:color-mix(in srgb,var(--accent) 25%,var(--surface));border-radius:5px}
js
const words=["R","Re","Rea","Reac","React"];let n=0;function tick(){const i=n%5;document.getElementById("query").textContent=words[i];document.getElementById("deferred").textContent=words[Math.max(0,i-2)];n++}tick();setInterval(tick,650)

useDeferredValue returns a lagging version of a value. React can paint urgent UI first and update the deferred result when work permits.

In the demo, the search text grows immediately while the result query follows later. Request cancellation and caching remain separate concerns.

When to use

Use it when typing must appear immediately but rendering results is slow.

Open as page ↗