Update use of deprecated React lifecycle methods
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, orcomponentWillUpdate. - 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 usingcomponentDidMount()instead ofcomponentWillMount().
Changelog entry
- N/A
@tofumatt anything more to add to this one?
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.
Moving this through to IB Review because I think it will make a good first issue to familiarise a developer with the codebase.
@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?
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 😄
IB ✅
@felixarntz is this an issue we want to include for the upcoming release?
Reopening as this was unintentionally closed by its connection to #1430 https://github.com/google/site-kit-wp/issues/860#event-3265992338
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.

Passed QA ✅