question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Log bug against aws-amplify use of componentWillReceiveProps instead of getDerivedStateFromProps

See original GitHub issue

Describe the bug In reference to aws-amplify-react-native/src/Auth/ConfirmSignUp.js

https://github.com/aws-amplify/amplify-js/blob/master/packages/aws-amplify-react-native/src/Auth/ConfirmSignUp.js

This react component still implements componentWillReceiveProps whereas this has been deprecated since React 16.3. This class should be updated to use getDerivedStateFromProps. This probably applies to all the Auth components.

To Reproduce Steps to reproduce the behavior:

  1. Implement an Auth workflow using AWS-Amplify
  2. When confirm sign up screen appears, the “username” field is blank

Expected behavior The username field should be pre-filled, because the user just signed up on the previous screen.

Actual behavior The field is blank.

Smartphone:

  • Tested on iPhone 8
  • iOS 12.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10

github_iconTop GitHub Comments

3reactions
sonufrienkocommented, Oct 9, 2019

React Native + TypeScript + Jest I got a warning:

Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.

Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: ConfirmSignUp

1reaction
melodymorgancommented, Nov 18, 2019

"react-native": "0.61.2",, slightly different use case. The following warning is logging in metro bundler,

 WARN  Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: ConfirmSignUp
Read more comments on GitHub >

github_iconTop Results From Across the Web

Lifecycle method static getDerivedStateFromProps doesn't ...
It sends new props if I console.log it in my render method, but getDerivedStateFromProps shows the same values both in prevState and newProps....
Read more >
shouldcomponentupdate react 17 Code Example - Code Grepper
react I want to make a request after the first render of a component is called, which life cycle should I use? willRecieveProps...
Read more >
amplify-redux-auth - dist - index.es.js.map - UNPKG
1, {"version":3,"file":"index.es.js","sources":["../node_modules/@babel/runtime/helpers/esm/extends.js","../node_modules/fbjs/lib/shallowEqual.js",".
Read more >
[Solved]-what is right way to do API call in react js?-Reactjs
In this case, you can do ajax call inside componentDidMount , and then update state export default class UserList extends React.
Read more >
Beginner's Thread / Easy Questions (March 2020) : reactjs
I have a backend hosted on AWS and a frontend hosted on Heroku, ... to fix a bug that was caused by importing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found