Skip to content

Commit

Permalink
fix: the problem of NoSSR with Suspense (#6221)
Browse files Browse the repository at this point in the history
  • Loading branch information
yimingjfe committed Sep 18, 2024
1 parent 3f968e1 commit 80825c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/orange-carrots-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/runtime': patch
---

fix: the problem of NoSSR with Suspense
fix: 修复 NoSSR 在 suspense 下 的问题
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import React, { type ReactElement, useEffect, useState } from 'react';
import React from 'react';
import { type ReactElement, useEffect, useState } from 'react';

let csr = false;
export const NoSSR = (
props: React.PropsWithChildren<{ fallback?: ReactElement | string }>,
) => {
const [isMounted, setMounted] = useState(csr);
props?: React.PropsWithChildren<{ fallback?: ReactElement | string }>,
): ReactElement | null => {
const [isMounted, setMounted] = useState(false);
useEffect(() => {
csr = true;
setMounted(true);
});
}, []);

const { children, fallback = null } = props;
const { children, fallback = null } = props || {};
return React.createElement(
React.Fragment,
null,
Expand Down

0 comments on commit 80825c4

Please sign in to comment.