Skip to content

Commit

Permalink
feat: update sample rendered code to only include component code
Browse files Browse the repository at this point in the history
  • Loading branch information
alharris-at committed Nov 16, 2021
1 parent c4767da commit 332124a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@

exports[`ReactStudioTemplateRenderer renderSampleCodeSnippet component with name 1`] = `
Object {
"compText": "export const App = () => {
return (<MyText />);
};",
"compText": "<MyText />",
"importsText": "import { MyText } from \\"./ui-components\\";
",
}
`;

exports[`ReactStudioTemplateRenderer renderSampleCodeSnippet component without name 1`] = `
Object {
"compText": "export const App = () => {
return (<unknown_component_name />);
};",
"compText": "<unknown_component_name />",
"importsText": "import { unknown_component_name } from \\"./ui-components\\";
",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer
const imports = this.importCollection.buildSampleSnippetImports(
this.component.name ?? StudioRendererConstants.unknownName,
);
const sampleAppName = 'App';

const { printer, file } = buildPrinter(this.fileName, this.renderConfig);
let importsText = '';
Expand All @@ -115,8 +114,7 @@ export abstract class ReactStudioTemplateRenderer extends StudioTemplateRenderer
importsText += result + EOL;
}

const wrapper = this.renderAppWrapper(sampleAppName, jsx);
const compText = printer.printNode(EmitHint.Unspecified, wrapper, file);
const compText = printer.printNode(EmitHint.Unspecified, jsx, file);

return { compText, importsText };
}
Expand Down

0 comments on commit 332124a

Please sign in to comment.