-
Notifications
You must be signed in to change notification settings - Fork 12
/
demo.tsx
44 lines (36 loc) · 971 Bytes
/
demo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import insertCss from 'insert-css'
import { StarRatingInput, StarRating, css } from './index'
class Container extends React.Component<{}, State> {
constructor(props: any) {
super(props)
this.handleChange = this.handleChange.bind(this)
this.state = { value: 0 }
}
render() {
return (
<div>
<h2>Interactive input</h2>
<StarRatingInput
size={5}
value={this.state.value}
onChange={this.handleChange} />
<br />
<h2>Static display</h2>
<StarRating value={4} />
</div>
)
}
handleChange(value: number): void {
this.setState({ value })
}
}
interface State {
value: number
}
insertCss(css)
ReactDOM.render(
<Container />,
document.getElementById('root')
)