Skip to content

Commit

Permalink
fix: make default "template" value to undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed May 29, 2022
1 parent f89a996 commit cb40927
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion public/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ Open editor at first.
<!-- sandpack:{
"files": {
"/src/index.js": {
"appendCode": "// 次の行は本編とは無関係のコードなので無視してください\nconst link = document.createElement('link');link.rel='stylesheet';link.href='https://jsprimer.net/use-case/todoapp/final/final/index.css';document.head.append(link);\n",
"code": "// This is auto generated by vanilla template",
"hidden": true
},
"/src/index2.js": {
"appendCode": "// Hack to load css\nconst link = document.createElement('link');link.rel='stylesheet';link.href='https://jsprimer.net/use-case/todoapp/final/final/index.css';document.head.append(link);\n",
"path": "example2/src/index.js"
},
"/src/App.js": {
Expand All @@ -51,7 +55,10 @@ Open editor at first.
"path": "example2/index.html"
}
},
"entry": "/src/index2.js",
"main": "/src/index2.js",
"environment": "static",
"template": "vanilla",
"options": {
"showLineNumbers": true,
"showInlineErrors": true,
Expand Down
4 changes: 2 additions & 2 deletions src/sandpack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type SandboxOptions = {
/**
* What template we use, if not defined we infer the template from the dependencies or files.
*/
template?: string;
template?: SandpackPredefinedTemplate;
options?: Record<string, any>; // Refer SandpackInternalProps
honkitSettings?: {
isOpen: boolean; // false by default
Expand Down Expand Up @@ -115,7 +115,7 @@ export const attachToElement = (element: HTMLElement | ChildNode, options: Sandb
};
const entry = options.entry;
const sandpackOptions = options.options;
const template = (options.template ?? "vanilla") as SandpackPredefinedTemplate;
const template = options.template;
currentRoot.render(
<Sandpack
files={files}
Expand Down

0 comments on commit cb40927

Please sign in to comment.