Skip to content

Commit f0bb3a7

Browse files
committed
Forward preview props
1 parent 9c7c33a commit f0bb3a7

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

packages/mdx/src/client/preview.tsx

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,32 @@ export function Preview({
3030
className={
3131
"ch-preview" + (className ? " " + className : "")
3232
}
33-
{...rest}
3433
>
35-
{!presetConfig ? (
36-
<MiniBrowser
37-
loadUrl={show}
38-
children={children}
39-
theme={codeConfig.theme}
40-
/>
41-
) : (
42-
<SandpackPreview
43-
files={files}
44-
presetConfig={presetConfig}
45-
codeConfig={codeConfig}
46-
/>
47-
)}
34+
<MiniBrowser
35+
loadUrl={show}
36+
theme={codeConfig.theme}
37+
{...rest}
38+
children={
39+
presetConfig ? (
40+
<SandpackPreview
41+
files={files}
42+
presetConfig={presetConfig}
43+
/>
44+
) : (
45+
children
46+
)
47+
}
48+
/>
4849
</div>
4950
)
5051
}
5152

5253
function SandpackPreview({
5354
files,
5455
presetConfig,
55-
codeConfig,
5656
}: {
5757
files: EditorStep["files"]
5858
presetConfig: PresetConfig
59-
codeConfig: { theme: EditorTheme }
6059
}) {
6160
const iframeRef = React.useRef<HTMLIFrameElement>(null!)
6261
const clientRef = React.useRef<SandpackClient>(null!)
@@ -85,12 +84,7 @@ function SandpackPreview({
8584
}
8685
}, [files])
8786

88-
return (
89-
// TODO only render iframe here, leave MiniBrowser for the parent component
90-
<MiniBrowser theme={codeConfig.theme}>
91-
<iframe ref={iframeRef} />
92-
</MiniBrowser>
93-
)
87+
return <iframe ref={iframeRef} />
9488
}
9589

9690
function mergeFiles(

0 commit comments

Comments
 (0)