add test components
This commit is contained in:
1 parent
034f8477b5
commit
09719f7788
5 files changed
+77
-1
No files matched your search
@@ -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('!');
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
|
||||
import Hello from "./components/Hello";
|
||||
|
||||
ReactDOM.render(
|
||||
<Hello name="TypeScript" enthusiasmLevel={10} />,
|
||||
document.getElementById('root') as HTMLElement
|
||||
);
|
||||
Reference in new issue
Block a user