forked from mui/toolpad
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
23 changed files
with
215 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+16.7 KB
docs/public/static/toolpad/docs/studio/concepts/page-properties/max-width.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,16 @@ | ||
import * as React from 'react'; | ||
|
||
function subscribe() { | ||
return () => {}; | ||
} | ||
|
||
function getSnapshot() { | ||
return false; | ||
} | ||
|
||
function getServerSnapshot() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Returns true when serverside rendering, or when hydrating. | ||
*/ | ||
export function useIsSsr(defer: boolean = false): boolean { | ||
const isSsrInitialValue = React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot); | ||
const [isSsr, setIsSsr] = React.useState(defer ? true : isSsrInitialValue); | ||
React.useEffect(() => setIsSsr(false), []); | ||
return isSsr; | ||
} | ||
import useSsr from '@toolpad/utils/hooks/useSsr'; | ||
|
||
export interface NoSsrProps { | ||
children?: React.ReactNode; | ||
fallback?: React.ReactNode; | ||
defer?: boolean; | ||
} | ||
|
||
/** | ||
* Alternative version of MUI NoSsr that avoids state updates during layout effects. | ||
*/ | ||
export default function NoSsr({ children, defer, fallback = null }: NoSsrProps) { | ||
const isSsr = useIsSsr(defer); | ||
export default function NoSsr({ children, fallback = null }: NoSsrProps) { | ||
const isSsr = useSsr(); | ||
|
||
return <React.Fragment>{isSsr ? fallback : children}</React.Fragment>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.