
React18 Dep Compatibility
Upgrade or validate Apollo Client against React 18 concurrent rendering and fix flaky GraphQL tests with MockedProvider.
Overview
React18-dep-compatibility is an agent skill for the Build phase that documents Apollo Client version requirements and test patterns for correct behavior under React 18 concurrent rendering.
Install
npx skills add https://github.com/github/awesome-copilot --skill react18-dep-compatibilityWhat is this skill?
- Maps Apollo versions (<3.7 through 3.11+) to React 18 and React 19 support with a version summary table
- Explains why Apollo 3.8+ adopts useSyncExternalStore for concurrent rendering and data tearing fixes
- Guides legacy ReactDOM.render vs createRoot migration triggers for Apollo 3.7 partial upgrades
- Documents MockedProvider async flush patterns under React 18 for stable unit and integration tests
- Version matrix covers Apollo from below 3.7 through 3.11+ with explicit React 18 and React 19 columns
Adoption & trust: 628 installs on skills.sh; 34.6k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You upgraded React to 18 or switched to createRoot and your Apollo-powered UI shows stale data, missed updates, or flaky MockedProvider tests with no obvious component bug.
Who is it for?
Indie devs upgrading React 18/19 on an existing Apollo 3.7 stack or debugging concurrent-mode GraphQL tearing in production-like apps.
Skip if: Greenfield projects already on Apollo 3.11+ with createRoot and stable tests, or teams not using Apollo Client at all.
When should I use this skill?
When upgrading React to 18+, migrating from ReactDOM.render to createRoot, or debugging Apollo GraphQL staleness and MockedProvider tests.
What do I get? / Deliverables
After the skill runs, you pick a supported Apollo version (3.8+ for createRoot), understand legacy-root caveats, and apply React 18–aware async test flushing for MockedProvider.
- Target Apollo Client version recommendation aligned to your React root API
- MockedProvider async test pattern notes for React 18
Recommended Skills
Journey fit
Canonical shelf is Build because compatibility decisions happen while wiring React frontends and GraphQL clients, not during idea research or post-launch SEO. Frontend subphase covers React root APIs, Apollo store subscriptions, and component-level test patterns tied to the UI stack.
How it compares
Use instead of guessing Apollo release notes from memory during a React upgrade—this skill is a focused compatibility sheet, not a full GraphQL architecture course.
Common Questions / FAQ
Who is react18-dep-compatibility for?
Solo and indie frontend builders shipping React apps with Apollo Client who need a fast, accurate version and testing compatibility reference during upgrades.
When should I use react18-dep-compatibility?
Use it in the Build frontend phase when moving to createRoot, evaluating Apollo 3.7 vs 3.8+, or fixing GraphQL-related test flakes; also briefly in Ship testing when MockedProvider async behavior regresses after a React bump.
Is react18-dep-compatibility safe to install?
It is documentation-only procedural knowledge with no bundled executables; review the Security Audits panel on this Prism page before installing any skill from the catalog.
SKILL.md
READMESKILL.md - React18 Dep Compatibility
# Apollo Client - React 18 Compatibility Details ## Why Apollo 3.8+ is Required Apollo Client 3.7 and below use an internal subscription model that is not compatible with React 18's concurrent rendering. In concurrent mode, React can interrupt and replay renders, which causes Apollo's store subscriptions to fire at incorrect times - producing stale data or missed updates. Apollo 3.8 was the first version to adopt `useSyncExternalStore`, which React 18 requires for external stores to work correctly under concurrent rendering. ## Version Summary | Apollo Version | React 18 Support | React 19 Support | Notes | |---|---|---|---| | < 3.7 | ❌ | ❌ | Concurrent mode data tearing | | 3.7.x | ⚠️ | ⚠️ | Works with legacy root only (ReactDOM.render) | | **3.8.x** | ✅ | ✅ | First fully compatible version | | 3.9+ | ✅ | ✅ | Recommended | | 3.11+ | ✅ | ✅ (confirmed) | Explicit React 19 testing added | ## If You're on Apollo 3.7 Using Legacy Root If the app still uses `ReactDOM.render` (legacy root) and hasn't migrated to `createRoot` yet, Apollo 3.7 will technically work - but this means you're not getting any React 18 concurrent features (including automatic batching). This is a partial upgrade only. As soon as `createRoot` is used, upgrade Apollo to 3.8+. ## MockedProvider in Tests - React 18 Apollo's `MockedProvider` works with React 18 but async behavior changed: ```jsx // Old pattern - flushing with setTimeout: await new Promise(resolve => setTimeout(resolve, 0)); wrapper.update(); // React 18 pattern - use waitFor or findBy: await waitFor(() => { expect(screen.getByText('Alice')).toBeInTheDocument(); }); // OR: expect(await screen.findByText('Alice')).toBeInTheDocument(); ``` ## Upgrading Apollo ```bash npm install @apollo/client@latest graphql@latest ``` If graphql peer dep conflicts with other packages: ```bash npm ls graphql # check what version is being used npm info @apollo/client peerDependencies # check what apollo requires ``` Apollo 3.8+ supports both `graphql@15` and `graphql@16`. ## InMemoryCache - No Changes Required `InMemoryCache` configuration is unaffected by the React 18 upgrade. No migration needed for: - `typePolicies` - `fragmentMatcher` - `possibleTypes` - Custom field policies ## useQuery / useMutation / useSubscription - No Changes Apollo hooks are unchanged in their API. The upgrade is entirely internal to how Apollo integrates with React's rendering model. # React Router v5 → v6 - Scope Assessment ## Why This Is a Separate Sprint React Router v5 → v6 is a complete API rewrite. Unlike most React 18 upgrade steps which touch individual patterns, the router migration affects: - Every `<Route>` component - Every `<Switch>` (replaced by `<Routes>`) - Every `useHistory()` (replaced by `useNavigate()`) - Every `useRouteMatch()` (replaced by `useMatch()`) - Every `<Redirect>` (replaced by `<Navigate>`) - Nested route definitions (entirely new model) - Route parameters access - Query string handling Attempting this as part of the React 18 upgrade sprint will scope-creep the migration significantly. ## Recommended Approach ### Option A - Defer Router Migration (Recommended) Use `react-router-dom@5.3.4` with `--legacy-peer-deps` during the React 18 upgrade. This is explicitly documented as a supported workaround by the react-router team for React 18 compatibility on legacy root. ```bash # In the React 18 dep surgeon: npm install react-router-dom@5.3.4 --legacy-peer-deps ``` Document in package.json: ```json "_legacyPeerDepsReason": { "react-router-dom@5.3.4": "Router v5→v6 migration deferred to separate sprint. React 18 peer dep mismatch only - no API incompatibility on legacy root." } ``` Then schedule the v5 → v6 migration as its own sprint after the React 18 upgrade is stable. ### Option B - Migrate Router as Part of React 18 Sprint Only choose this if: - The app has minimal routing (< 10 routes, no nested routes, no complex navigation logic) - The team has bandwidth and the