diff --git a/modules/mixins/Helpers.js b/modules/mixins/Helpers.js index 690919bc..5d9fcfd4 100644 --- a/modules/mixins/Helpers.js +++ b/modules/mixins/Helpers.js @@ -236,24 +236,22 @@ const Helpers = { } componentDidMount() { - if (typeof window === 'undefined') { - return false; - } this.registerElems(this.props.name); } - componentWillReceiveProps(nextProps) { - if (this.props.name !== nextProps.name) { - this.registerElems(nextProps.name); + componentDidUpdate(prevProps) { + if (this.props.name !== prevProps.name) { + this.registerElems(this.props.name); } } componentWillUnmount() { - if (typeof window === 'undefined') { - return false; + if (typeof window !== 'undefined') { + defaultScroller.unregister(this.props.name); } - defaultScroller.unregister(this.props.name); } registerElems(name) { - defaultScroller.register(name, this.childBindings.domNode); + if (typeof window !== 'undefined') { + defaultScroller.register(name, this.childBindings.domNode); + } } render() { return React.createElement(Component, Object.assign({}, this.props, { parentBindings: this.childBindings })); diff --git a/modules/mixins/scroll-element.js b/modules/mixins/scroll-element.js index 735ed844..4077f136 100644 --- a/modules/mixins/scroll-element.js +++ b/modules/mixins/scroll-element.js @@ -15,24 +15,22 @@ export default (Component) => { } componentDidMount() { - if (typeof window === 'undefined') { - return false; - } this.registerElems(this.props.name); } - componentWillReceiveProps(nextProps) { - if (this.props.name !== nextProps.name) { - this.registerElems(nextProps.name); + componentDidUpdate(prevProps) { + if (this.props.name !== prevProps.name) { + this.registerElems(this.props.name); } } componentWillUnmount() { - if (typeof window === 'undefined') { - return false; + if (typeof window !== 'undefined') { + scroller.unregister(this.props.name); } - scroller.unregister(this.props.name); } registerElems(name) { - scroller.register(name, this.childBindings.domNode); + if (typeof window !== 'undefined') { + scroller.register(name, this.childBindings.domNode); + } } render() { return React.createElement(Component, Object.assign({}, this.props, { parentBindings: this.childBindings }));