Skip to content

Commit

Permalink
fix(UncontrolledDropdown): Fix onToggle - a consistent isOpen value
Browse files Browse the repository at this point in the history
  • Loading branch information
jdrobiecki authored and phwebi committed Sep 8, 2021
1 parent 90be17a commit ee54164
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/UncontrolledDropdown.js
Expand Up @@ -14,10 +14,12 @@ export default class UncontrolledDropdown extends Component {
}

toggle(e) {
this.setState({ isOpen: !this.state.isOpen });
if (this.props.onToggle) {
this.props.onToggle(e, !this.state.isOpen);
}
const isOpen = !this.state.isOpen;
this.setState({ isOpen }, () => {
if (this.props.onToggle) {
this.props.onToggle(e, isOpen);
}
});
}

render() {
Expand Down

0 comments on commit ee54164

Please sign in to comment.