From d90857ab32b5a0f492c599c9e38340ff64b72432 Mon Sep 17 00:00:00 2001 From: tianyingchun Date: Sat, 3 Oct 2015 22:53:59 +0800 Subject: [PATCH 1/2] bug fix https://github.com/react-component/dropdown/issues/2 --- src/Tooltip.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Tooltip.jsx b/src/Tooltip.jsx index dfa73c6..3e1872b 100644 --- a/src/Tooltip.jsx +++ b/src/Tooltip.jsx @@ -60,9 +60,12 @@ const Tooltip = React.createClass({ const props = this.props; const state = this.state; if (this.popupRendered) { - const self = this; - React.render(this.getPopupElement(), this.getTipContainer(), function renderPopup() { - self.popupInstance = this; + // const self = this; + //Render a ReactElement into the DOM in the supplied container and return a reference to the component. + this.popupInstance = React.render(this.getPopupElement(), this.getTipContainer(), function renderPopup() { + // self.popupInstance = this; + // FIXME maybe react can't make sure the `this` always is rendered component. + // if (prevState.visible !== state.visible) { props.afterVisibleChange(state.visible); } From cc3f646cf3a2601c16a9d80da29179578a297d9f Mon Sep 17 00:00:00 2001 From: tianyingchun Date: Sun, 4 Oct 2015 00:00:56 +0800 Subject: [PATCH 2/2] bug fix --- src/Tooltip.jsx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Tooltip.jsx b/src/Tooltip.jsx index 3e1872b..5c51dd1 100644 --- a/src/Tooltip.jsx +++ b/src/Tooltip.jsx @@ -60,16 +60,14 @@ const Tooltip = React.createClass({ const props = this.props; const state = this.state; if (this.popupRendered) { - // const self = this; + //Render a ReactElement into the DOM in the supplied container and return a reference to the component. - this.popupInstance = React.render(this.getPopupElement(), this.getTipContainer(), function renderPopup() { - // self.popupInstance = this; - // FIXME maybe react can't make sure the `this` always is rendered component. - // - if (prevState.visible !== state.visible) { - props.afterVisibleChange(state.visible); - } - }); + this.popupInstance = React.render(this.getPopupElement(), this.getTipContainer()); + + // Remove callback, why need to put below code into callback. + if (prevState.visible !== state.visible) { + props.afterVisibleChange(state.visible); + } if (props.trigger.indexOf('click') !== -1) { if (state.visible) { if (!this.clickOutsideHandler) {