Skip to content

Commit 846a45e

Browse files
committed
Only use new ID generation when using SSR
1 parent edaf52a commit 846a45e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

src/components/Space.tsx

-4
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ const SpaceInner: React.FC<IReactSpaceInnerProps & { wrapperInstance: Space }> =
7777
if (SSR_SUPPORT_ENABLED && !isServer()) {
7878
const preRenderedStyle = document.getElementById(`style_${idToUse}_ssr`);
7979
if (preRenderedStyle) {
80-
// const newStyle = document.createElement("style");
81-
// newStyle.id = `style_${idToUse}`;
82-
// newStyle.innerHTML = preRenderedStyle.innerHTML;
83-
// document.head.appendChild(newStyle);
8480
space.ssrStyle = preRenderedStyle.innerHTML;
8581
}
8682
updateStyleDefinition(space);

src/core-react.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@ export function useForceUpdate() {
118118
}
119119

120120
export function useUniqueId() {
121-
if (React.version.startsWith("18")) {
122-
return `s${React.useId().replace(/\:/g, "")}`;
123-
}
121+
if (SSR_SUPPORT_ENABLED) {
122+
if (React.version.startsWith("18")) {
123+
return `s${React.useId().replace(/\:/g, "")}`;
124+
}
124125

125-
if ((React as any).unstable_useOpaqueIdentifier) {
126-
return `s${(React as any).unstable_useOpaqueIdentifier().replace(/\:/g, "")}`;
126+
if ((React as any).unstable_useOpaqueIdentifier) {
127+
return `s${(React as any).unstable_useOpaqueIdentifier().replace(/\:/g, "")}`;
128+
}
127129
}
128130

129131
return `s${shortuuid()}`;

0 commit comments

Comments
 (0)