Skip to content

Commit

Permalink
fix(react): ensure hidden files even for templates (#231)
Browse files Browse the repository at this point in the history
* fix(react): ensure hidden files even for templates

* fix: types

* refacor
  • Loading branch information
danilowoz committed Dec 9, 2021
1 parent 51be6cf commit a1461a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sandpack-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export type SandpackStatus =
export type EditorState = "pristine" | "dirty";

export interface SandboxTemplate {
files: SandpackBundlerFiles;
files: Record<string, SandpackFile>;
dependencies: Record<string, string>;
devDependencies?: Record<string, string>;
entry: string;
Expand Down
8 changes: 7 additions & 1 deletion sandpack-react/src/utils/sandpackUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ export const getSandpackStateFromProps = (

if (openPaths.length === 0) {
// If no files are received, use the project setup / template
openPaths = Object.keys(projectSetup.files);
openPaths = Object.keys(projectSetup.files).reduce<string[]>((acc, key) => {
if (!projectSetup.files[key].hidden) {
acc.push(key);
}

return acc;
}, []);
}

// If no activePath is specified, use the first open file
Expand Down

0 comments on commit a1461a0

Please sign in to comment.