Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"postinstall": "is-ci || (cd .. && husky install beta/.husky)"
},
"dependencies": {
"@codesandbox/sandpack-react": "^0.1.20",
"@codesandbox/sandpack-react": "0.3.8-alpha.4",
"@docsearch/css": "3.0.0-alpha.41",
"@docsearch/react": "3.0.0-alpha.41",
"@headlessui/react": "^1.3.0",
Expand Down
25 changes: 15 additions & 10 deletions beta/src/components/MDX/Sandpack/CustomPreset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ import {flushSync} from 'react-dom';
import {
useSandpack,
useActiveCode,
SandpackCodeEditor,
SandpackThemeProvider,
} from '@codesandbox/sandpack-react';
import { SandpackCodeEditor } from "@codesandbox/sandpack-react/dist/components/CodeEditor"

import scrollIntoView from 'scroll-into-view-if-needed';

import {IconChevron} from 'components/Icon/IconChevron';
import {NavigationBar} from './NavigationBar';
import {Preview} from './Preview';
import {CustomTheme} from './Themes';

// const SandpackCodeEditor = React.lazy(() => import('@codesandbox/sandpack-react/dist/components/CodeEditor').then(module => module.SandpackCodeEditor) as any)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 Just curious, why have we used React.lazy instead of the dynamic import that is provided by Next.js?

https://nextjs.org/docs/advanced-features/dynamic-import


export function CustomPreset({
isSingleFile,
onReset,
Expand Down Expand Up @@ -60,15 +63,17 @@ export function CustomPreset({
// There has to be some better way to do this...
minHeight: 216,
}}>
<SandpackCodeEditor
customStyle={{
height: getHeight(),
maxHeight: isExpanded ? '' : 406,
}}
showLineNumbers
showInlineErrors
showTabs={false}
/>
<React.Suspense fallback={<pre>{code}</pre>}>
<SandpackCodeEditor
customStyle={{
height: getHeight(),
maxHeight: isExpanded ? '' : 406,
}}
showLineNumbers
showInlineErrors
showTabs={false}
/>
</React.Suspense>
<Preview
isExpanded={isExpanded}
className="order-last xl:order-2"
Expand Down
3 changes: 3 additions & 0 deletions beta/src/components/MDX/Sandpack/SandpackCodeEditorLazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { SandpackCodeEditor } from "@codesandbox/sandpack-react/dist/components/CodeEditor"

export default SandpackCodeEditor
2 changes: 2 additions & 0 deletions beta/src/components/MDX/Sandpack/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ function Sandpack(props: SandpackProps) {
return (
<div className="my-8" translate="no">
<SandpackProvider
// TODO: remove it
bundlerURL="https://0-3-0-sandpack.codesandbox.io/"
key={key}
template="react"
customSetup={{...setup, files: files}}
Expand Down
Loading