react18-batching-patterns

tarafından github

React 18 sınıf bileşenlerinde otomatik toplama (automatic batching) gerilemelerini teşhis etmek ve düzeltmek için kesin desenler sağlar. Bir sınıf bileşeni… olduğunda bu yeteneği kullanın.

npx skills add https://github.com/github/awesome-copilot --skill react18-batching-patterns

React 18 Automatic Batching Patterns

Reference for diagnosing and fixing the most dangerous silent breaking change in React 18 for class-component codebases.

The Core Change

Location of setStateReact 17React 18
React event handlerBatchedBatched (same)
setTimeoutImmediate re-renderBatched
Promise .then() / .catch()Immediate re-renderBatched
async/awaitImmediate re-renderBatched
Native addEventListener callbackImmediate re-renderBatched

Batched means: all setState calls within that execution context flush together in a single re-render at the end. No intermediate renders occur.

Quick Diagnosis

Read every async class method. Ask: does any code after an await read this.state to make a decision?

Code reads this.state after await?
  YES → Category A (silent state-read bug)
  NO, but intermediate render must be visible to user?
    YES → Category C (flushSync needed)
    NO → Category B (refactor, no flushSync)

For the full pattern for each category, read:

  • references/batching-categories.md - Category A, B, C with full before/after code
  • references/flushSync-guide.md - when to use flushSync, when NOT to, import syntax

The flushSync Rule

Use flushSync sparingly. It forces a synchronous re-render, bypassing React 18's concurrent scheduler. Overusing it negates the performance benefits of React 18.

Only use flushSync when:

  • The user must see an intermediate UI state before an async operation begins
  • A spinner/loading state must render before a fetch starts
  • Sequential UI steps have distinct visible states (progress wizard, multi-step flow)

In most cases, the fix is a refactor - restructuring the code to not read this.state after await. Read references/batching-categories.md for the correct approach per category.

github tarafından daha fazla skill

console-rendering
github
Go'da struct etiketi tabanlı konsol renderlama sistemini kullanma talimatları
official
acquire-codebase-knowledge
github
Bu beceriyi, kullanıcı açıkça mevcut bir kod tabanını haritalamayı, belgelemeyi veya bu kod tabanına dahil olmayı istediğinde kullanın. "Bu kod tabanını haritala", "belgele…" gibi ifadeler için tetikleyin.
official
acreadiness-assess
github
Run the AgentRC readiness assessment on the current repository and produce a static HTML dashboard at reports/index.html. Wraps `npx github:microsoft/agentrc…
official
acreadiness-generate-instructions
github
AgentRC talimatları komutu aracılığıyla özelleştirilmiş AI ajan talimat dosyaları oluşturur. .github/copilot-instructions.md dosyasını üretir (varsayılan, VS'de Copilot için önerilir…
official
acreadiness-policy
github
Kullanıcının bir AgentRC politikası seçmesine, yazmasına veya uygulamasına yardımcı olun. Politikalar, ilgisiz kontrolleri devre dışı bırakarak, etki/seviyeyi geçersiz kılarak, ayarlayarak…
official
add-educational-comments
github
We need to translate the given English text into Turkish, preserving the name "add-educational-comments" if it appears. The text is a description of an agent skill. We must not add any extra commentary, labels, or formatting. The translation should be accurate and natural in Turkish. The text: "Add educational comments to code files to transform them into effective learning resources. Adapts explanation depth and tone to three configurable knowledge levels: beginner, intermediate, and advanced Automatically requests a file if none is provided, with numbered list matching for quick selection Expands files by up to 125% using educational comments only (hard limit: 400 new lines; 300 for files over 1,000 lines) Preserves file encoding, indentation style, syntax correctness, and..." It seems cut off at the end. The original might have more, but we only have this. We'll translate what's given. Note: The name "add-educational-comments" does not appear in the text, so we don't include it. Translation: "Kod dosyalarına
official
adobe-illustrator-scripting
github
ExtendScript (JavaScript/JSX) kullanarak Adobe Illustrator otomasyon betiklerini yazın, hata ayıklayın ve optimize edin. Oluştururken veya değiştirirken kullanın…
official
agent-governance
github
Yapay zeka aracı erişimi ve davranışını kontrol etmek için bildirimsel politikalar, niyet sınıflandırması ve denetim izleri. Birleştirilebilir yönetişim politikaları, izin verilen/engellenen araçları, içerik filtrelerini, hız sınırlarını ve onay gereksinimlerini tanımlar — kod değil yapılandırma olarak saklanır. Anlamsal niyet sınıflandırması, araç yürütülmeden önce desen tabanlı sinyaller kullanarak tehlikeli istemleri (veri sızdırma, ayrıcalık yükseltme, istem enjeksiyonu) tespit eder. Araç düzeyinde yönetişim dekoratörü, politikaları işlevde u
official