From 719c2e9d9a401cc051987cc0151c1d9c0d27de9e Mon Sep 17 00:00:00 2001 From: Ben Wheeler <wheeler.benjamin@gmail.com> Date: Mon, 8 Oct 2018 15:27:08 -0400 Subject: [PATCH] project-saver-hoc changed componentWillReceiveProps to componentDidUpdate --- src/lib/project-saver-hoc.jsx | 12 +++++------- src/lib/vm-listener-hoc.jsx | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/project-saver-hoc.jsx b/src/lib/project-saver-hoc.jsx index 867428d9c..20fdee849 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 70e7eb131..d67465842 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}); -- GitLab