Skip to content

fix: add React 19 / SSR compatibility guards#1363

Merged
sserrata merged 1 commit intomainfrom
fix/react19-ssr-compat-partial
Mar 30, 2026
Merged

fix: add React 19 / SSR compatibility guards#1363
sserrata merged 1 commit intomainfrom
fix/react19-ssr-compat-partial

Conversation

@sserrata
Copy link
Copy Markdown
Member

Summary

Applies the three approved changes from #1257, dropping the hooks.ts changes that violated Rules of Hooks.

  • Schema/index.tsx: Return null early when oneOf/anyOf array is empty or undefined, preventing zero TabItems from reaching SchemaTabs.
  • SchemaTabs/index.tsx: Filter null/undefined children before calling sanitizeTabsChildren; wrap it in try-catch; return null if no valid children survive. Prevents the "Tabs requires at least one TabItem" crash.
  • MethodEndpoint/index.tsx: Early-return a static (no server URL) render during SSR via ExecutionEnvironment.canUseDOM, preventing useSelector from running outside a Redux Provider during build/hydration.

The hooks.ts try-catch wrappers from the original PR were intentionally excluded — they violate Rules of Hooks and introduce async state where useSelector is synchronous.

Related

Test plan

  • yarn build-packages passes with no TypeScript errors
  • npm run build in a Docusaurus 3.x project with React 19 no longer throws SSR Redux errors
  • OpenAPI specs with oneOf: [] / anyOf: [] no longer crash the build

🤖 Generated with Claude Code

- Schema: return null for empty oneOf/anyOf arrays instead of
  passing zero TabItems to SchemaTabs (which would throw)
- SchemaTabs: filter null/undefined children and wrap
  sanitizeTabsChildren in try-catch; return null if no valid
  children survive sanitization
- MethodEndpoint: early-return a static render during SSR to
  avoid useSelector running outside a Redux Provider

Closes #1130. Partial credit to @stuartbuckell (PR #1257).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Size Change: 0 B

Total Size: 2.2 MB

ℹ️ View Unchanged
Filename Size
demo/.docusaurus/codeTranslations.json 2 B
demo/.docusaurus/docusaurus.config.mjs 14.7 kB
demo/.docusaurus/globalData.json 65.4 kB
demo/.docusaurus/i18n.json 372 B
demo/.docusaurus/registry.js 94.7 kB
demo/.docusaurus/routes.js 89.6 kB
demo/.docusaurus/routesChunkNames.json 37.1 kB
demo/.docusaurus/site-metadata.json 1.51 kB
demo/build/assets/css/styles.********.css 164 kB
demo/build/assets/js/main.********.js 656 kB
demo/build/assets/js/runtime~main.********.js 22.3 kB
demo/build/index.html 97.6 kB
demo/build/petstore/add-pet/index.html 29.3 kB
demo/build/petstore/create-user/index.html 24 kB
demo/build/petstore/create-users-with-array-input/index.html 24.1 kB
demo/build/petstore/create-users-with-list-input/index.html 24.1 kB
demo/build/petstore/delete-order/index.html 23.8 kB
demo/build/petstore/delete-pet/index.html 24.1 kB
demo/build/petstore/delete-user/index.html 24.3 kB
demo/build/petstore/find-pets-by-status/index.html 24.8 kB
demo/build/petstore/find-pets-by-tags/index.html 25.4 kB
demo/build/petstore/get-inventory/index.html 23.1 kB
demo/build/petstore/get-order-by-id/index.html 24.1 kB
demo/build/petstore/get-pet-by-id/index.html 24.9 kB
demo/build/petstore/get-user-by-name/index.html 24.4 kB
demo/build/petstore/login-user/index.html 24.9 kB
demo/build/petstore/logout-user/index.html 23.7 kB
demo/build/petstore/new-pet/index.html 24.3 kB
demo/build/petstore/pet/index.html 22.5 kB
demo/build/petstore/place-order/index.html 23.3 kB
demo/build/petstore/schemas/apiresponse/index.html 24.6 kB
demo/build/petstore/schemas/cat/index.html 38.8 kB
demo/build/petstore/schemas/category/index.html 25.7 kB
demo/build/petstore/schemas/dog/index.html 39 kB
demo/build/petstore/schemas/honeybee/index.html 39.1 kB
demo/build/petstore/schemas/id/index.html 22.7 kB
demo/build/petstore/schemas/order/index.html 26.8 kB
demo/build/petstore/schemas/pet/index.html 38.6 kB
demo/build/petstore/schemas/tag/index.html 24.1 kB
demo/build/petstore/schemas/user/index.html 40.7 kB
demo/build/petstore/store/index.html 21.5 kB
demo/build/petstore/subscribe-to-the-store-events/index.html 30.2 kB
demo/build/petstore/swagger-petstore-yaml/index.html 30.2 kB
demo/build/petstore/update-pet-with-form/index.html 24.3 kB
demo/build/petstore/update-pet/index.html 24.7 kB
demo/build/petstore/update-user/index.html 24.3 kB
demo/build/petstore/upload-file/index.html 24.1 kB
demo/build/petstore/user/index.html 22.2 kB

compressed-size-action

@github-actions
Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 5f89b25):

https://docusaurus-openapi-36b86--pr1363-klzohos5.web.app

(expires Wed, 29 Apr 2026 16:33:15 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata sserrata merged commit 22d48e4 into main Mar 30, 2026
11 checks passed
@sserrata sserrata deleted the fix/react19-ssr-compat-partial branch March 30, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update docusaurus-theme-openapi-docs dependencies for React 19 compatibility

1 participant