[Fix] Load react-json-view browser-only (SSR document crash) - #1726
Conversation
@microlink/react-json-view touches `document` at module-eval time, so it threw ReferenceError under SSR (via json-view -> citations / playground run-detail) despite the "use client" directive. Load it through next/dynamic with ssr:false; the InteractionProps import becomes type-only.
|
@CREDO23 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
@microlink/react-json-viewreadsdocumentat module-eval time, throwingReferenceError: document is not definedunder SSR (viajson-view-> citations panel / playground run-detail) despite"use client".next/dynamicwithssr: false;InteractionPropsbecomes a type-only import. Single importer, so all consumers are covered.Test plan
/dashboard/.../new-chat/*returns 200 with nodocument is not definedHigh-level PR Summary
This PR fixes a server-side rendering (SSR) crash caused by
@microlink/react-json-viewaccessing thedocumentobject during module evaluation. The fix wraps the component import with Next.js'sdynamic()function and disables SSR (ssr: false), ensuring the library only loads in the browser. TheInteractionPropstype is converted to a type-only import since it doesn't require runtime evaluation.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
surfsense_web/components/json-view.tsx