Skip to content
Snippets Groups Projects
Commit 719c2e9d authored by Ben Wheeler's avatar Ben Wheeler
Browse files

project-saver-hoc changed componentWillReceiveProps to componentDidUpdate

parent 469094b4
No related branches found
No related tags found
No related merge requests found
...@@ -22,25 +22,23 @@ const ProjectSaverHOC = function (WrappedComponent) { ...@@ -22,25 +22,23 @@ const ProjectSaverHOC = function (WrappedComponent) {
bindAll(this, [ bindAll(this, [
'storeProject' // NOTE: do i need to bind this? 'storeProject' // NOTE: do i need to bind this?
]); ]);
this.state = {
};
} }
componentWillReceiveProps (nextProps) { componentDidUpdate (prevProps) {
if (nextProps.isSavingWithId && !this.props.isSavingWithId) { if (this.props.isSavingWithId && !prevProps.isSavingWithId) {
this.storeProject({ this.storeProject({
action: 'update', action: 'update',
id: nextProps.reduxProjectId id: this.props.reduxProjectId
}) })
.then(response => { // eslint-disable-line no-unused-vars .then(response => { // eslint-disable-line no-unused-vars
// NOTE: should we check/handle response value here? // NOTE: should we check/handle response value here?
this.props.doneSavingWithId(nextProps.projectState); this.props.doneSavingWithId(this.props.projectState);
}) })
.catch(err => { .catch(err => {
// NOTE: should throw up a notice for user // NOTE: should throw up a notice for user
this.props.goToErrorState(`Saving the project failed with error: ${err}`); this.props.goToErrorState(`Saving the project failed with error: ${err}`);
}); });
} }
if (nextProps.isCreatingNew && !this.props.isCreatingNew) { if (this.props.isCreatingNew && !prevProps.isCreatingNew) {
this.storeProject({ this.storeProject({
action: 'create' action: 'create'
}) })
......
...@@ -49,6 +49,8 @@ const vmListenerHOC = function (WrappedComponent) { ...@@ -49,6 +49,8 @@ const vmListenerHOC = function (WrappedComponent) {
} }
this.props.vm.postIOData('userData', {username: this.props.username}); this.props.vm.postIOData('userData', {username: this.props.username});
} }
// NOTE: should consider changing this to another lifecycle method, e.g. componentDidUpdate,
// because componentWillReceiveProps is deprecated
componentWillReceiveProps (newProps) { componentWillReceiveProps (newProps) {
if (newProps.username !== this.props.username) { if (newProps.username !== this.props.username) {
this.props.vm.postIOData('userData', {username: newProps.username}); this.props.vm.postIOData('userData', {username: newProps.username});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment