site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Update use of deprecated React lifecycle methods

Open aaemnnosttv opened this issue 7 years ago • 9 comments

Bug Description

Some React lifecycle methods have been deprecated and will be removed in v17. Let's make sure these are updated accordingly.

See https://fb.me/react-async-component-lifecycle-hooks

This seems to be the only case but there may be more: https://github.com/google/site-kit-wp/blob/cb0b1e104b0c6348af2ffdc58d1396aa9b585cda/assets/js/components/notifications/dashboard-wins-alerts.js#L42


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • No warnings from our own code are displayed because of componentWillMount, componentWillReceiveProps , or componentWillUpdate .
  • Optional, but encouraged: upgrade any dependencies (if there are any—I think there are) that still rely on these methods to versions that no longer rely on them.
  • No usage of UNSAFE_ methods, eg. UNSAFE_componentWillMount.

Implementation Brief

  • Update https://github.com/google/site-kit-wp/blob/cb0b1e104b0c6348af2ffdc58d1396aa9b585cda/assets/js/components/notifications/dashboard-wins-alerts.js#L42 not to use componentWillMount. From the look of that method, it should work fine using componentDidMount() instead of componentWillMount().

Changelog entry

  • N/A

aaemnnosttv avatar Nov 14 '19 10:11 aaemnnosttv

@tofumatt anything more to add to this one?

aaemnnosttv avatar Nov 14 '19 10:11 aaemnnosttv

Nothing to add; looks like that component could probably just be changed to a componentDidMount() relatively easily and still work.

Note that some dependencies we use might still be using deprecated lifecycle methods, so it's possible we'll still see warnings after fixing this as our dependencies update. I don't think anything we use shows the warning though so we should be good.

tofumatt avatar Nov 14 '19 17:11 tofumatt

Moving this through to IB Review because I think it will make a good first issue to familiarise a developer with the codebase.

tofumatt avatar Apr 13 '20 19:04 tofumatt

@tofumatt

to use a safer, better way to accomplish their task.

This is very high-level - could you add a bit more info on it?

felixarntz avatar Apr 13 '20 20:04 felixarntz

Fair enough! In the case of that method it should actually work fine as componentDidMount instead of componentWillMount, and I don't see any other unsafe/deprecated methods in our own code base, so that should be enough for the non-optional parts of the AC/IB 😄

tofumatt avatar Apr 13 '20 21:04 tofumatt

IB ✅

aaemnnosttv avatar Apr 14 '20 09:04 aaemnnosttv

@felixarntz is this an issue we want to include for the upcoming release?

aaemnnosttv avatar Apr 24 '20 14:04 aaemnnosttv

Reopening as this was unintentionally closed by its connection to #1430 https://github.com/google/site-kit-wp/issues/860#event-3265992338

aaemnnosttv avatar May 01 '20 07:05 aaemnnosttv

Tested

Ran regression on the production ready zip for 1.8.0

Setup SK, activated all modules, removed modules, reset SK, re-setup SK and confirmed functionality of all modules again.

image

Passed QA ✅

cole10up avatar May 07 '20 03:05 cole10up