forked from microsoft/fluentui
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: improve lazy loading in v0 docs (microsoft#13777)
* chore: improve lazy loading in v0 docs * fix chunk comment * fix merge issues, remove default exports * restore change
- Loading branch information
1 parent
3cc14fd
commit b53685f
Showing
13 changed files
with
260 additions
and
139 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
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
27 changes: 27 additions & 0 deletions
27
packages/fluentui/docs/src/components/ComponentDoc/SourceRender.tsx
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import useScript from '@charlietango/use-script'; | ||
import { Loader } from '@fluentui/react-northstar'; | ||
import * as React from 'react'; | ||
|
||
const _SourceRender = React.lazy(() => import('react-source-render')); | ||
|
||
type SourceRenderProps = { | ||
babelConfig?: Record<string, any>; | ||
hot?: boolean; | ||
resolver?: (importPath: string, context?: Object) => void; | ||
resolverContext?: Object; | ||
source: string; | ||
onRender?: (error: Error | null) => void; | ||
}; | ||
|
||
export const SourceRender: React.FC<SourceRenderProps> = props => { | ||
const url = `https://cdn.jsdelivr.net/npm/@babel/standalone@${window['versions'].babelStandalone}/babel.min.js`; | ||
const [ready] = useScript(url); | ||
|
||
return ready ? ( | ||
<React.Suspense fallback={<Loader />}> | ||
<_SourceRender {...props} /> | ||
</React.Suspense> | ||
) : ( | ||
<Loader /> | ||
); | ||
}; |
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.