Latihan 1 dari materi Debugging React di Debugging — praktek dengan editor kode interaktif, test case otomatis, dan hint terpandu. Langsung jalan di browser.
Simulasikan React DevTools Profiler — analisis render log.
Setiap entry profiler: { component, duration, reason, props, state }. reason salah satu: "mount", "props", "state", "parent", "hooks".
1. profilerSummary(renders)
Return object:
totalDuration — total durasi render (sum, dibulatkan ke integer)byReason — object count render per reasonslowestComponent — nama component dengan total durasi tertinggi2. findWastedRenders(renders)
reason === "parent" tapi props & state sama persis dengan render sebelumnya untuk component yang sama.3. recommendMemo(renders, threshold)
React.memo: component dengan ≥ threshold wasted render.