add test components

This commit is contained in:
zhandouxiaojiji committed 2020-10-09 16:11:20 +08:00
1 parent 034f8477b5
commit 09719f7788
5 files changed
+77 -1

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
import * as React from 'react';
export interface Props {
name: string;
enthusiasmLevel?: number;
}
export default class Hello extends React.Component<Props, object> {
render() {
const { name, enthusiasmLevel = 1 } = this.props;
if (enthusiasmLevel <= 0) {
throw new Error('You could be a little more enthusiastic. :D');
}
return (
<div className="hello">
<div className="greeting">
Hello {name + getExclamationMarks(enthusiasmLevel)}
</div>
</div>
);
}
}
function getExclamationMarks(numChars: number) {
return Array(numChars + 1).join('!');
}