diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e2e22128..90af7ec82 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,5 @@ { "eslint.enable": false, - "javascript.validate.enable": false + "javascript.validate.enable": false, + "typescript.tsdk": "node_modules/typescript/lib" } diff --git a/packages/docz-theme-default/src/components/ui/Render/index.tsx b/packages/docz-theme-default/src/components/ui/Render/index.tsx index e379df992..092311d52 100644 --- a/packages/docz-theme-default/src/components/ui/Render/index.tsx +++ b/packages/docz-theme-default/src/components/ui/Render/index.tsx @@ -146,8 +146,19 @@ export class Render extends Component { hotkeys.unbind('esc') } + get showingContent(): string { + const { code, component } = this.props + const { showing } = this.state + + const content = { + jsx: () => code, + html: () => pretty(renderToStaticMarkup(component)), + } + + return content[showing]() + } + get actions(): JSX.Element { - const { code } = this.props const { showing, fullscreen } = this.state const showJsx = this.handleShow('jsx') @@ -163,7 +174,7 @@ export class Render extends Component { HTML - + { } public render(): JSX.Element { - const { className, style, component, code } = this.props - const { showing, fullscreen } = this.state + const { className, style, component } = this.props + const { fullscreen } = this.state return ( @@ -225,11 +236,7 @@ export class Render extends Component { {component} {this.actions} -
}>
-              {showing === 'jsx'
-                ? code
-                : pretty(renderToStaticMarkup(component))}
-            
+
}>{this.showingContent}