|
5 | 5 | * LICENSE file in the root directory of this source tree. |
6 | 6 | * ========================================================================== */ |
7 | 7 |
|
8 | | -import React, { Suspense } from "react"; |
| 8 | +import React, { Suspense, useEffect, useState } from "react"; |
9 | 9 |
|
10 | | -import BrowserOnly from "@docusaurus/BrowserOnly"; |
11 | 10 | import Details from "@theme/Details"; |
12 | 11 | import MimeTabs from "@theme/MimeTabs"; // Assume these components exist |
13 | 12 | import { |
@@ -38,6 +37,25 @@ const ResponseSchemaComponent: React.FC<Props> = ({ |
38 | 37 | body, |
39 | 38 | style, |
40 | 39 | }): any => { |
| 40 | + const [isClient, setIsClient] = useState(false); |
| 41 | + |
| 42 | + useEffect(() => { |
| 43 | + setIsClient(true); |
| 44 | + }, []); |
| 45 | + |
| 46 | + if (!isClient) { |
| 47 | + return ( |
| 48 | + <div className="openapi-explorer__loading-container"> |
| 49 | + <div className="openapi-response__lds-ring"> |
| 50 | + <div></div> |
| 51 | + <div></div> |
| 52 | + <div></div> |
| 53 | + <div></div> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + ); |
| 57 | + } |
| 58 | + |
41 | 59 | if ( |
42 | 60 | body === undefined || |
43 | 61 | body.content === undefined || |
@@ -131,30 +149,13 @@ const ResponseSchemaComponent: React.FC<Props> = ({ |
131 | 149 | }; |
132 | 150 |
|
133 | 151 | const ResponseSchema: React.FC<Props> = (props) => { |
| 152 | + const LazyComponent = React.lazy(() => |
| 153 | + Promise.resolve({ default: ResponseSchemaComponent }) |
| 154 | + ); |
134 | 155 | return ( |
135 | | - <BrowserOnly |
136 | | - fallback={ |
137 | | - <div className="openapi-explorer__loading-container"> |
138 | | - <div className="openapi-response__lds-ring"> |
139 | | - <div></div> |
140 | | - <div></div> |
141 | | - <div></div> |
142 | | - <div></div> |
143 | | - </div> |
144 | | - </div> |
145 | | - } |
146 | | - > |
147 | | - {() => { |
148 | | - const LazyComponent = React.lazy(() => |
149 | | - Promise.resolve({ default: ResponseSchemaComponent }) |
150 | | - ); |
151 | | - return ( |
152 | | - <Suspense fallback={<div>Loading...</div>}> |
153 | | - <LazyComponent {...props} /> |
154 | | - </Suspense> |
155 | | - ); |
156 | | - }} |
157 | | - </BrowserOnly> |
| 156 | + <Suspense fallback={<div>Loading...</div>}> |
| 157 | + <LazyComponent {...props} /> |
| 158 | + </Suspense> |
158 | 159 | ); |
159 | 160 | }; |
160 | 161 |
|
|
0 commit comments