react-stripe-elements icon indicating copy to clipboard operation
react-stripe-elements copied to clipboard

Replace use of deprecated lifecycle method componentWillReceiveProps

Open rynobax opened this issue 6 years ago • 10 comments

Summary & motivation

When rendered in React Strict mode, this library generates warnings because it is using the deprecated lifecycle method componentWillReceiveProps. I moved the code inside of componentWillReceiveProps into componentDidUpdate, as suggested in this React blog post.

Testing & documentation

The changes to the the code needed to remove cWRP was pretty straightforward. However, Enzyme v2 does not call cDU, so I migrated the tests to enzyme v3 in order to get them to pass. There are other ways to keep the tests passing without upgrading Enzyme (namely switching from shallow rendering to full mounting), but this seemed the simplest.

I also fixed a bug in the demo page that was exposed by strict mode, where a request was being fired in the constructor, and the handler was running before the component had been mounted (which threw an error). Moving the request into componentDidMount fixed it.

rynobax avatar Oct 07 '18 04:10 rynobax

@rynobax thanks for this PR! On a cursory look, it seems like a change worth making. Can you look into the CI error and get things green so we can do a full review? Thanks!

asolove-stripe avatar Oct 09 '18 20:10 asolove-stripe

CI is passing now

rynobax avatar Oct 09 '18 23:10 rynobax

👍

rynobax avatar Oct 12 '18 17:10 rynobax

@rynobax you planning on fixing the simple conflict so this can get merged?

caseybaggz avatar Jan 30 '19 19:01 caseybaggz

Rebased the branch and let yarn fix the conflict

rynobax avatar Jan 31 '19 01:01 rynobax

Thank you for updating this PR! Unfortunately we are no closer to a major version release than when this PR was opened. We will keep this in mind for the future when other breaking changes are introduced.

(Happy to take a separate PR for the enzyme changes though if you'd like)

atty-stripe avatar Jan 31 '19 21:01 atty-stripe

Hi, now Rect 16.9 deprecates componentWillReceiveProps, it would be useful to merge this!

y0hnn avatar Aug 17 '19 11:08 y0hnn

@yohannprigent: good point! Looks like I need to rebase and review this, since it's a bit old, but we should get 16.9 support working soon.

asolove-stripe avatar Aug 19 '19 17:08 asolove-stripe

A fix for this is now in master and we will cut a 5.0 release shortly, so going to close. Thanks for the PR and sorry we took so long to get around to this!

asolove-stripe avatar Aug 27 '19 15:08 asolove-stripe

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

CLAassistant avatar Aug 06 '20 12:08 CLAassistant