Skip to content

Instantly share code, notes, and snippets.

@atmd83
Last active February 27, 2018 12:16
Show Gist options
  • Save atmd83/8ade2d7787c8b5b3453f4b616eec30e7 to your computer and use it in GitHub Desktop.
Save atmd83/8ade2d7787c8b5b3453f4b616eec30e7 to your computer and use it in GitHub Desktop.
Medium post
import React from 'react';
import PubSub from 'pubsub-js';
export default class Thing extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
PubSub.publish('thing.did.mount');
}
componentWillReceiveProps(nextProps, nextState) {
PubSub.publish('thing.will.receive.props');
return true
}
shouldComponentUpdate(nextProps, nextState) {
PubSub.publish('thing.should.update');
return true;
}
componentWillUpdate(nextProps, nextState) {
PubSub.publish('thing.will.update');
return true;
}
componentWillUnmount() {
PubSub.publish('thing.will.unmount');
}
render() {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment