@@ -32,6 +32,7 @@ export class Space extends React.Component<IReactSpaceInnerProps> {
3232
3333const SpaceInner : React . FC < IReactSpaceInnerProps & { wrapperInstance : Space } > = ( props ) => {
3434 let idToUse = props . id ?? props . wrapperInstance [ "_react_spaces_uniqueid" ] ;
35+ const [ initialRender , setInitialRender ] = React . useState ( SSR_SUPPORT_ENABLED ? true : false ) ;
3536
3637 const uniqueId = useUniqueId ( ) ;
3738
@@ -76,17 +77,23 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =
7677 if ( SSR_SUPPORT_ENABLED && ! isServer ( ) ) {
7778 const preRenderedStyle = document . getElementById ( `style_${ idToUse } _ssr` ) ;
7879 if ( preRenderedStyle ) {
79- const newStyle = document . createElement ( "style" ) ;
80- newStyle . id = `style_${ idToUse } ` ;
81- newStyle . innerHTML = preRenderedStyle . innerHTML ;
82- document . head . appendChild ( newStyle ) ;
80+ // const newStyle = document.createElement("style");
81+ // newStyle.id = `style_${idToUse}`;
82+ // newStyle.innerHTML = preRenderedStyle.innerHTML;
83+ // document.head.appendChild(newStyle);
8384 space . ssrStyle = preRenderedStyle . innerHTML ;
8485 }
8586 updateStyleDefinition ( space ) ;
8687 }
8788
8889 useEffectOnce ( ( ) => {
8990 space . element = elementRef . current ! ;
91+
92+ if ( SSR_SUPPORT_ENABLED ) {
93+ if ( initialRender ) {
94+ setInitialRender ( false ) ;
95+ }
96+ }
9097 } ) ;
9198
9299 const userClasses = className ? className . split ( " " ) . map ( ( c ) => c . trim ( ) ) : [ ] ;
@@ -127,11 +134,7 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =
127134 return (
128135 < >
129136 { resizeHandles . mouseHandles . map ( ( handleProps ) => handleRender ?.( handleProps ) || < div { ...handleProps } /> ) }
130- { SSR_SUPPORT_ENABLED && space . ssrStyle ? (
131- < style id = { `style_${ space . id } _ssr` } > { space . ssrStyle } </ style >
132- ) : (
133- < style id = { `style_${ space . id } _ssr` } />
134- ) }
137+ { SSR_SUPPORT_ENABLED && space . ssrStyle && initialRender && < style id = { `style_${ space . id } _ssr` } > { space . ssrStyle } </ style > }
135138 { React . createElement (
136139 props . as || "div" ,
137140 outerProps ,
0 commit comments