Skip to content

Commit

Permalink
Add dynamic registration
Browse files Browse the repository at this point in the history
  • Loading branch information
buhuitou committed Jan 4, 2017
1 parent 132a0de commit 67c2c98
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 67c2c98

Please sign in to comment.