Skip to content

Commit

Permalink
[fixed] guard against async setState
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Feb 16, 2016
1 parent bd11101 commit 8805757
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ module.exports = React.createClass({
, duration = this.props.duration;

this.animate(el, offset, duration, 'ease', () =>
this.setState({ status: CLOSED }, () => {
this.safeSetState({ status: CLOSED }, () => {
this.props.onClose()
})
)
Expand Down
3 changes: 2 additions & 1 deletion src/mixins/FocusMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export default function FocusMixin({ willHandle, didHandle }) {

if (focused !== inst.state.focused) {
notify(handler, event)
inst.setState({ focused })
if (inst.isMounted())
inst.setState({ focused })
}
})
})
Expand Down

0 comments on commit 8805757

Please sign in to comment.