Skip to content

Commit

Permalink
🐛 Remove ill-considered lifecycle
Browse files Browse the repository at this point in the history
The 'componentWillReceiveProps' lifecycle method wasn't well considered,
and presents considerable problems when manually adding/setting streams.
It's better to remove this and leave this kind of implimentation in
userland.
  • Loading branch information
Douglas Brown committed Oct 13, 2016
1 parent 9f89fcc commit 9bac893
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-flyd-component",
"version": "2.0.0",
"version": "2.1.0",
"description": "Live-Updating Stateless React Components Using Flyd",
"main": "lib/index.js",
"scripts": {
Expand Down
25 changes: 0 additions & 25 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,6 @@ export class StreamingComponent extends Component {
this._onUpdate = combine(this.onStreamUpdate.bind(this));
}

/**
* componentWillReceiveProps
*
* Handles changes to props for this component
* (but only where streams are added or removed).
*
* Built-in React lifecylce.
*
* @param {Object} nextProps
* @returns {void}
*/
componentWillReceiveProps(nextProps) {
const newStreams = getStreamsFromProps(nextProps);

// it doesn't make much sense that streams would
// be conditionally present, but hey who am I to judge.
// this will clearly not automatically update if two streams
// are swapped-out (length is equal but streams are different).
// that's what `clearStreams` is for, so it should be
// invoked manually if you try that junk. *wontfix*
if (newStreams.length !== this._streams.length) {
this.clearStreams(newStreams);
}
}

/**
* componentWillMount
*
Expand Down

0 comments on commit 9bac893

Please sign in to comment.