From 7f9b457a413588c76114e846058f37e2e2e4e9af Mon Sep 17 00:00:00 2001
From: yue
Date: Tue, 4 Jun 2024 22:12:47 +0900
Subject: [PATCH] fix: avoid ssrprovider for react 18
---
.../src/pages/@charcoal-ui/react/ssr.page.tsx | 2 +-
docs/yarn.lock | 80 +++++++++----------
packages/react/README.md | 2 +-
packages/react/src/core/SSRProvider.tsx | 12 ++-
4 files changed, 53 insertions(+), 43 deletions(-)
diff --git a/docs/src/pages/@charcoal-ui/react/ssr.page.tsx b/docs/src/pages/@charcoal-ui/react/ssr.page.tsx
index 954494d6a..8d87a0a06 100644
--- a/docs/src/pages/@charcoal-ui/react/ssr.page.tsx
+++ b/docs/src/pages/@charcoal-ui/react/ssr.page.tsx
@@ -16,7 +16,7 @@ export default function InstallPage() {
SSRProvider
- SSRを利用する際はSSRProvider
+ React 18 以下で SSRを利用する際はSSRProvider
をアプリケーションに適用してください。
=17.0.0"
styled-components: ">=5.1.1"
- checksum: b102add505337058e1d2f733a7366e504db5997e025f8cf2d6bdf9819d9fb35717a2e490e22db5963415a5b823f716cea2b1e4d45d5b355e6aa27d7c2c726451
+ checksum: e0625d63a3ea9c2523f60b01b72f17d886f622168b2168fe9a7d54a82c231ff3245a7cd205db6660a5c5193bbdf80019c228315b287d7f36d49075c62f65b5f3
languageName: node
linkType: hard
"@charcoal-ui/styled@file:../packages/styled::locator=charcoal-web-docs%40workspace%3A.":
- version: 3.12.0
- resolution: "@charcoal-ui/styled@file:../packages/styled#../packages/styled::hash=6e3708&locator=charcoal-web-docs%40workspace%3A."
+ version: 3.13.0-beta.0
+ resolution: "@charcoal-ui/styled@file:../packages/styled#../packages/styled::hash=858e6a&locator=charcoal-web-docs%40workspace%3A."
dependencies:
- "@charcoal-ui/foundation": ^3.12.0
- "@charcoal-ui/theme": ^3.12.0
- "@charcoal-ui/utils": ^3.12.0
+ "@charcoal-ui/foundation": ^3.13.0-beta.0
+ "@charcoal-ui/theme": ^3.13.0-beta.0
+ "@charcoal-ui/utils": ^3.13.0-beta.0
warning: ^4.0.3
peerDependencies:
react: ">=17.0.0"
styled-components: ">=5.1.1"
- checksum: ef3e20f6904bbbc7d0ac701af6a741885ae4af3bc84bf1a4e308fb91722a78e2c79249347867dda400410a7ab3788ab0e14f9d4bb802503c810617484079f24a
+ checksum: e8f9f91ce7c8fc15efb0553daadace40eba064429e24aad64d4c50dd9303f335c36325b3cf183f7f668173d8e519f95ea65fbf3c856c82a484f81add393e4291
languageName: node
linkType: hard
"@charcoal-ui/tailwind-config@file:../packages/tailwind-config::locator=charcoal-web-docs%40workspace%3A.":
- version: 3.12.0
- resolution: "@charcoal-ui/tailwind-config@file:../packages/tailwind-config#../packages/tailwind-config::hash=de3c83&locator=charcoal-web-docs%40workspace%3A."
+ version: 3.13.0-beta.0
+ resolution: "@charcoal-ui/tailwind-config@file:../packages/tailwind-config#../packages/tailwind-config::hash=360b23&locator=charcoal-web-docs%40workspace%3A."
dependencies:
- "@charcoal-ui/foundation": ^3.12.0
- "@charcoal-ui/theme": ^3.12.0
- "@charcoal-ui/utils": ^3.12.0
+ "@charcoal-ui/foundation": ^3.13.0-beta.0
+ "@charcoal-ui/theme": ^3.13.0-beta.0
+ "@charcoal-ui/utils": ^3.13.0-beta.0
peerDependencies:
csstype: ">=3.0.0"
postcss: ">=7.0.32"
tailwindcss: ">=1.4.6"
- checksum: 674ab9152d98ff89be92557961b6850b65b86ea3e1a5d8c888e75aed3173261d593bfd8f3aaf7fd1bab95cd2df881279ac49c755b7f80c6e24a6b6d213bb2bfa
+ checksum: 853275aa37607f20384ac7d25b46b2a2dfd83ff5c2bf74b06e805515a65123be216b5fdb689bb97542c8d707fbfed8b1150214fefc7b20fedbdef2cf05166d27
languageName: node
linkType: hard
"@charcoal-ui/theme@file:../packages/theme::locator=charcoal-web-docs%40workspace%3A.":
- version: 3.12.0
- resolution: "@charcoal-ui/theme@file:../packages/theme#../packages/theme::hash=67be88&locator=charcoal-web-docs%40workspace%3A."
+ version: 3.13.0-beta.0
+ resolution: "@charcoal-ui/theme@file:../packages/theme#../packages/theme::hash=d9cc7c&locator=charcoal-web-docs%40workspace%3A."
dependencies:
- "@charcoal-ui/foundation": ^3.12.0
- "@charcoal-ui/utils": ^3.12.0
+ "@charcoal-ui/foundation": ^3.13.0-beta.0
+ "@charcoal-ui/utils": ^3.13.0-beta.0
polished: ^4.1.4
- checksum: 14347705aa521c0cac884e746a2a8ea0b92daedb3587b7f78c0997769b281c74117dca3c61cbdcbdc25eff7ebe096bb2b0a51a2923c0f494f7c06c9fc3847aa6
+ checksum: 4a85a0b9505e4ba0eaa593e904f1b6943b533798d160e9bbcbbf6dc078574849def8cd37f37fbbfe2c6818dd3925175f238ff19954ccf55482cf1f5b11b8d289
languageName: node
linkType: hard
"@charcoal-ui/utils@file:../packages/utils::locator=charcoal-web-docs%40workspace%3A.":
- version: 3.12.0
- resolution: "@charcoal-ui/utils@file:../packages/utils#../packages/utils::hash=5c00f3&locator=charcoal-web-docs%40workspace%3A."
+ version: 3.13.0-beta.0
+ resolution: "@charcoal-ui/utils@file:../packages/utils#../packages/utils::hash=dbde2f&locator=charcoal-web-docs%40workspace%3A."
dependencies:
- "@charcoal-ui/foundation": ^3.12.0
+ "@charcoal-ui/foundation": ^3.13.0-beta.0
polished: ^4.1.4
- checksum: f0bf2b06d40f04feadb40cb2b6e203cbf7653554d2674e5652b85f161a66cf187c52a7da6f1bc2e21db43b9aa1dd356c3d604f2ff3cc24c82b73c104b7b47f5d
+ checksum: f14f5519b41e1d8e6f6fa2c0aaaac7f196ee71d130666ef4b10f3a9dc600388831c2ad31dea91f962b3cbac782084c3b07be9af0e943ab8452e8a22554d84957
languageName: node
linkType: hard
diff --git a/packages/react/README.md b/packages/react/README.md
index 2e49ff837..bec673966 100644
--- a/packages/react/README.md
+++ b/packages/react/README.md
@@ -18,7 +18,7 @@ yarn add @charcoal-ui/react
## Server Side Rendering を行う場合の注意点
-SSR を行う場合はアプリケーション全体を``で囲む必要があります。
+React 18 以下で SSR を行う場合はアプリケーション全体を``で囲む必要があります。
```jsx
import { SSRProvider } from '@charcoal-ui/react'
diff --git a/packages/react/src/core/SSRProvider.tsx b/packages/react/src/core/SSRProvider.tsx
index 9d20c6f8c..ddec59c02 100644
--- a/packages/react/src/core/SSRProvider.tsx
+++ b/packages/react/src/core/SSRProvider.tsx
@@ -1 +1,11 @@
-export { SSRProvider } from '@react-aria/ssr'
+import { SSRProvider as OriginSSRProvider } from '@react-aria/ssr'
+import { version, Fragment } from 'react'
+
+export function isReactVersionOver(minVersion: number): boolean {
+ const reactMajorVersion = parseInt(version.split('.')[0], 10)
+ return Number.isFinite(reactMajorVersion)
+ ? reactMajorVersion >= minVersion
+ : false
+}
+
+export const SSRProvider = isReactVersionOver(18) ? Fragment : OriginSSRProvider