React Compiler lint diagnostics

React 컴파일러 린트 진단

Find React rule violations so the compiler can optimize code safely.

···
html
<div class="scene"><div class="editor"><div class="line">function Counter() {</div><div class="line" id="bad">  setCount(count + 1) <span>warning</span></div><div class="line" id="good">  onClick={() => setCount(count + 1)} <span>valid</span></div><div class="line">  return &lt;button /&gt;</div><div class="line">}</div></div><div class="badge" id="badge">RULE VIOLATION</div><div class="cache" id="cache">CACHE BOUNDARY: OFF</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}.editor{background:var(--bg);border:1px solid var(--line);border-radius:8px;padding:.6em;font:500 clamp(12px,3vmin,15px)/1.35 ui-monospace,monospace;white-space:nowrap;overflow:hidden}.line{margin:.25em 0}.line span{color:var(--accent-3)}#good{display:none}#good span{color:var(--accent)}.badge,.cache{margin-top:clamp(9px,3vmin,17px);padding:.45em;border-radius:6px;text-align:center;font-weight:700}.badge{background:color-mix(in srgb,var(--accent-3) 18%,var(--surface));color:var(--accent-3)}.cache{border:1px dashed var(--line);color:var(--muted)}.cache.on{border-color:var(--accent);color:var(--accent)}
js
let fixed=false;function tick(){fixed=!fixed;document.getElementById("bad").style.display=fixed?"none":"block";document.getElementById("good").style.display=fixed?"block":"none";document.getElementById("badge").textContent=fixed?"RULES PASS":"RULE VIOLATION";document.getElementById("cache").textContent=fixed?"CACHE BOUNDARY: ON":"CACHE BOUNDARY: OFF";document.getElementById("cache").classList.toggle("on",fixed)}tick();setInterval(tick,1500)

Compiler-powered lint rules diagnose React rule violations such as setting state during render or unsafe ref access. Fixing a violation can make a component eligible for automatic optimization again.

The demo moves a render-time state update out of render, clears the warning, and enables a cache boundary. Passing lint alone does not guarantee faster rendering; measure performance separately.

When to use

Use it while adopting React Compiler or cleaning up hook and render rule violations.

Open as page ↗