5
5
* LICENSE file in the root directory of this source tree.
6
6
* ========================================================================== */
7
7
8
- import React from "react" ;
8
+ import React , { Suspense , useEffect , useState } from "react" ;
9
9
10
10
import Details from "@theme/Details" ;
11
11
import MimeTabs from "@theme/MimeTabs" ; // Assume these components exist
@@ -26,7 +26,28 @@ interface Props {
26
26
} ;
27
27
}
28
28
29
- const RequestSchema : React . FC < Props > = ( { title, body, style } ) => {
29
+ const RequestSchemaComponent : React . FC < Props > = ( { title, body, style } ) => {
30
+ const [ isClient , setIsClient ] = useState ( false ) ;
31
+
32
+ useEffect ( ( ) => {
33
+ if ( typeof window !== "undefined" ) {
34
+ setIsClient ( true ) ;
35
+ }
36
+ } , [ ] ) ;
37
+
38
+ if ( ! isClient ) {
39
+ return (
40
+ < div className = "openapi-explorer__loading-container" >
41
+ < div className = "openapi-response__lds-ring" >
42
+ < div > </ div >
43
+ < div > </ div >
44
+ < div > </ div >
45
+ < div > </ div >
46
+ </ div >
47
+ </ div >
48
+ ) ;
49
+ }
50
+
30
51
if (
31
52
body === undefined ||
32
53
body . content === undefined ||
@@ -142,4 +163,15 @@ const RequestSchema: React.FC<Props> = ({ title, body, style }) => {
142
163
) ;
143
164
} ;
144
165
166
+ const RequestSchema : React . FC < Props > = ( props ) => {
167
+ const LazyComponent = React . lazy ( ( ) =>
168
+ Promise . resolve ( { default : RequestSchemaComponent } )
169
+ ) ;
170
+ return (
171
+ < Suspense fallback = { < div > Loading...</ div > } >
172
+ < LazyComponent { ...props } />
173
+ </ Suspense >
174
+ ) ;
175
+ } ;
176
+
145
177
export default RequestSchema ;
0 commit comments