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) {
bindAll(this, [
'storeProject' // NOTE: do i need to bind this?
]);
this.state = {
};
}
componentWillReceiveProps (nextProps) {
if (nextProps.isSavingWithId && !this.props.isSavingWithId) {
componentDidUpdate (prevProps) {
if (this.props.isSavingWithId && !prevProps.isSavingWithId) {
this.storeProject({
action: 'update',
id: nextProps.reduxProjectId
id: this.props.reduxProjectId
})
.then(response => { // eslint-disable-line no-unused-vars
// NOTE: should we check/handle response value here?
this.props.doneSavingWithId(nextProps.projectState);
this.props.doneSavingWithId(this.props.projectState);
})
.catch(err => {
// NOTE: should throw up a notice for user
this.props.goToErrorState(`Saving the project failed with error: ${err}`);
});
}
if (nextProps.isCreatingNew && !this.props.isCreatingNew) {
if (this.props.isCreatingNew && !prevProps.isCreatingNew) {
this.storeProject({
action: 'create'
})
......
......@@ -49,6 +49,8 @@ const vmListenerHOC = function (WrappedComponent) {
}
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) {
if (newProps.username !== this.props.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