react18-batching-patterns

Provides exact patterns for diagnosing and fixing automatic batching regressions in React 18 class components. Use this skill whenever a class component has…

INSTALLATION
npx skills add https://github.com/github/awesome-copilot --skill react18-batching-patterns
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$28

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.

BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card