diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx index 867428d9c078e248943b0aca2c929b44fc439908..20fdee849b157445fd3f53cd413246ad6e1667d5 100644 --- a/src/lib/project-saver-hoc.jsx +++ b/src/lib/project-saver-hoc.jsx @@ -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' }) diff --git a/src/lib/vm-listener-hoc.jsx b/src/lib/vm-listener-hoc.jsx index 70e7eb131dc0fa92c6af55b6aa084681f34f45e6..d67465842cfc63d15c721bab295f094be3be4fa4 100644 --- a/src/lib/vm-listener-hoc.jsx +++ b/src/lib/vm-listener-hoc.jsx @@ -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});