-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve type-safety when using createFileMap
#5428
base: main
Are you sure you want to change the base?
Conversation
@@ -46,20 +46,20 @@ const SandpackGlimmer = ({code}: {code: string}) => ( | |||
); | |||
|
|||
export default memo(function SandpackWrapper(props: any): any { | |||
const codeSnippet = createFileMap(Children.toArray(props.children)); | |||
const codeSnippets = Children.toArray(props.children) as React.ReactElement[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using same pattern as beta/src/components/MDX/Sandpack/SandpackRoot.tsx
. Should we pass files
as a prop instead of recomputing in beta/src/components/MDX/Sandpack/SandpackRoot.tsx
?
Size Changes📦 Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action 🤖 Three Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -74,7 +74,7 @@ function SandpackRoot(props: SandpackProps) { | |||
|
|||
files['/styles.css'] = { | |||
code: [sandboxStyle, files['/styles.css']?.code ?? ''].join('\n\n'), | |||
hidden: !files['/styles.css']?.visible, | |||
hidden: files['/styles.css']?.hidden, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
files
used to be any
since createFileMap
returned any
. Now that we type the input of createFileMap
, TypeScript is able to infer a more accurate return type of createFileMap
.
@@ -74,7 +74,7 @@ function SandpackRoot(props: SandpackProps) { | |||
|
|||
files['/styles.css'] = { | |||
code: [sandboxStyle, files['/styles.css']?.code ?? ''].join('\n\n'), | |||
hidden: !files['/styles.css']?.visible, | |||
hidden: files['/styles.css']?.hidden, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't find neither css styles.css hidden
nor css styles.css visible
so maybe this should be
hidden: files['/styles.css']?.hidden, | |
hidden: true, |
instead which would match the old behavior?
Extracted from #5426