Skip to content

Commit edaf52a

Browse files
committed
Fix
1 parent 14417a0 commit edaf52a

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

rollup.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import babel from "@rollup/plugin-babel";
55
import sourcemaps from "rollup-plugin-sourcemaps";
66
import postcss from "rollup-plugin-postcss";
77
import { uglify } from "rollup-plugin-uglify";
8-
import css from "rollup-plugin-import-css";
98
import pkg from "./package.json";
109

1110
const commonPlugins = [

src/components/Space.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class Space extends React.Component<IReactSpaceInnerProps> {
3232

3333
const 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

Comments
 (0)