diff --git a/.changeset/twenty-rules-attend.md b/.changeset/twenty-rules-attend.md
new file mode 100644
index 0000000000..a9d656fc9d
--- /dev/null
+++ b/.changeset/twenty-rules-attend.md
@@ -0,0 +1,5 @@
+---
+'@ice/runtime': patch
+---
+
+fix: runtime should compatible with old browsers
diff --git a/packages/runtime/src/Document.tsx b/packages/runtime/src/Document.tsx
index 242f95f8b3..d48baf32c1 100644
--- a/packages/runtime/src/Document.tsx
+++ b/packages/runtime/src/Document.tsx
@@ -187,7 +187,7 @@ export const Data: DataType = (props: DataProps) => {
// Should merge global context when there are multiple .
);
};
diff --git a/packages/runtime/src/Suspense.tsx b/packages/runtime/src/Suspense.tsx
index adc745a511..5323436308 100644
--- a/packages/runtime/src/Suspense.tsx
+++ b/packages/runtime/src/Suspense.tsx
@@ -28,9 +28,18 @@ const SuspenseContext = React.createContext(undefined
const getHydrateData = (id: string) => {
let data = null;
- const hasHydrateData = isClient && window[LOADER] && window[LOADER].has(id);
- if (hasHydrateData) {
- data = window[LOADER].get(id);
+ const loaderData = isClient && window[LOADER];
+ let hasHydrateData: boolean;
+ if (loaderData) {
+ // Compatible with the old version which use Map to store data.
+ if (loaderData.has) {
+ hasHydrateData = loaderData.has(id);
+ data = window[LOADER].get(id);
+ } else {
+ hasHydrateData = Object.prototype.hasOwnProperty.call(loaderData, id);
+ // If hasHydrateData is false, data will be undefined.
+ data = window[LOADER][id];
+ }
}
return {
hasHydrateData,
@@ -157,6 +166,6 @@ function Data(props) {
const data = useSuspenseData();
return (
-
+
);
}