Update StarRating.md
This commit is contained in:
@ -30,18 +30,18 @@ class StarRating extends React.Component {
|
|||||||
selection: 0
|
selection: 0
|
||||||
};
|
};
|
||||||
this.hoverOver = this.hoverOver.bind(this);
|
this.hoverOver = this.hoverOver.bind(this);
|
||||||
this.setRating = this.setRating.bind(this);
|
this.handleClick = this.handleClick.bind(this);
|
||||||
}
|
}
|
||||||
hoverOver(val) {
|
hoverOver(val) {
|
||||||
this.setState(state => ({ selection: val }));
|
this.setState(state => ({ selection: val }));
|
||||||
}
|
}
|
||||||
setRating(event) {
|
handleClick(event) {
|
||||||
const val = event.target.getAttribute('star-id') || this.state.rating;
|
const val = event.target.getAttribute('star-id') || this.state.rating;
|
||||||
this.setState(state => ({ rating: val }));
|
this.setState(state => ({ rating: val }));
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div onMouseOut={() => this.hoverOver(0)} onClick={this.setRating}>
|
<div onMouseOut={() => this.hoverOver(0)} onClick={this.handleClick}>
|
||||||
{Array.from({ length: 5 }, (v, i) => i + 1).map(v => (
|
{Array.from({ length: 5 }, (v, i) => i + 1).map(v => (
|
||||||
<Star
|
<Star
|
||||||
starId={v}
|
starId={v}
|
||||||
|
|||||||
Reference in New Issue
Block a user