Frontend: React 18 Automatic Batching (Renders Per Update)
MediumTypeScript
Description
> This problem is paper-only - see explanation for the canonical React reasoning.
React 18 automatic batching combines multiple state updates inside the same event/microtask into a single re-render. Pre-18, only updates inside React event handlers were batched.
The auto-grader validates how many renders a sequence of state-update calls produces, given the React version.
Input: `{ version: 17 | 18, context: "react-event" | "promise" | "settimeout" | "native-event", numberOfSetStates }`. Return the number of renders.
**Rules:**
- React 18: any context with `numberOfSetStates >= 1` produces exactly **1** render.
- React 17 in `react-event`: 1 render.
- React 17 in `promise` / `settimeout` / `native-event`: `numberOfSetStates` renders (one per call).
- `numberOfSetStates === 0`: 0 renders.
**For the auto-grader:** implement `renderCount(input)`.