Skip to content

Commit

Permalink
Merge pull request unclecheese#3 from buhuitou/add-dynamic-registration
Browse files Browse the repository at this point in the history
Add dynamic registration
  • Loading branch information
buhuitou committed Jan 4, 2017
2 parents 132a0de + 67c2c98 commit 6857db7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dist/react-selectable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,14 @@ return /******/ (function(modules) { // webpackBootstrap
value: function componentWillUnmount() {
this.context.selectable.unregister(this.props.selectableKey);
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps(nextProps) {
if (this.props.selectableKey === nextProps.selectableKey) return;

this.context.selectable.unregister(this.props.selectableKey);
this.context.selectable.register(nextProps.selectableKey, _reactDom2.default.findDOMNode(this));
}
}, {
key: 'render',
value: function render() {
Expand Down
7 changes: 7 additions & 0 deletions src/createSelectable.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ const createSelectable = (WrappedComponent) => {
this.context.selectable.unregister(this.props.selectableKey);
}

componentWillReceiveProps(nextProps) {
if (this.props.selectableKey === nextProps.selectableKey) return;

this.context.selectable.unregister(this.props.selectableKey);
this.context.selectable.register(nextProps.selectableKey, ReactDOM.findDOMNode(this));
}


render () {
return React.createElement(
Expand Down

0 comments on commit 6857db7

Please sign in to comment.