Skip to content

Commit 31d79a2

Browse files
committed
fixed the formatting using prettier
1 parent 5cbbcae commit 31d79a2

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/CodePreview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CodePreview extends Component<Props> {
2626
}}
2727
>
2828
<SyntaxHighlighter style={hybrid}>
29-
{componentRender(focusComponent, components)}
29+
{format(componentRender(focusComponent, components))}}
3030
</SyntaxHighlighter>
3131
</div>
3232
);

src/utils/componentRender.util.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ const componentRender = (component: ComponentInt, components: ComponentsInt) =>
136136
};
137137
138138
${classBased ? `class ${title} extends Component {` : `const ${title} = (props: Props) => {`}
139-
${stateful && !classBased ? `const hey = useState(INITIAL VALUE FOR PROP);` : ``}
139+
${
140+
stateful && !classBased
141+
? `const [prop, setProp] = useState("INITIAL VALUE FOR PROP");`
142+
: ``
143+
}
140144
${
141145
classBased && stateful
142146
? `constructor(props) {
@@ -146,8 +150,8 @@ const componentRender = (component: ComponentInt, components: ComponentsInt) =>
146150
: ``
147151
}
148152
149-
const {${props.map(el => el.key).join(', ')}} = props;
150-
${classBased ? `render() {` : ``}
153+
${classBased ? `render(): JSX.Element {` : ``}
154+
const {${props.map(el => el.key).join(', ')}} = ${classBased ? `this.props` : `props`};
151155
return (
152156
<div>
153157
${cloneDeep(childrenArray)

0 commit comments

Comments
 (0)