Skip to content

Commit

Permalink
fix(Rating): prevent triggering onChange when value not changed,close #…
Browse files Browse the repository at this point in the history
…3639 (#4251)

Co-authored-by: 林俊 <[email protected]>
  • Loading branch information
jun599 and 林俊 authored Feb 27, 2023
1 parent 0abbfaa commit 410454a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/rating/rating.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ class Rating extends Component {
this.setState({ value: isReset ? 0 : newValue, clicked: true });
}

this.props.onChange(isReset ? 0 : newValue);
if (newValue !== value || isReset) {
this.props.onChange(isReset ? 0 : newValue);
}
setTimeout(() => {
this.setState({ clicked: false });
}, 100);
Expand Down

0 comments on commit 410454a

Please sign in to comment.