From 880575780a7762165ce5196d64587890ab6d5375 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Thu, 11 Feb 2016 14:47:40 -0500 Subject: [PATCH] [fixed] guard against async setState --- src/Popup.jsx | 2 +- src/mixins/FocusMixin.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Popup.jsx b/src/Popup.jsx index 76824ca40..0ee32baa4 100644 --- a/src/Popup.jsx +++ b/src/Popup.jsx @@ -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() }) ) diff --git a/src/mixins/FocusMixin.js b/src/mixins/FocusMixin.js index f500d779b..937b99fdf 100644 --- a/src/mixins/FocusMixin.js +++ b/src/mixins/FocusMixin.js @@ -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 }) } }) })