Amplify-js: Log bug against aws-amplify use of componentWillReceiveProps instead of getDerivedStateFromProps

Created on 17 Apr 2019  路  9Comments  路  Source: aws-amplify/amplify-js

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
React needs-discussion pending-close-response-required

Most helpful comment

_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

All 9 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue has been automatically closed because of inactivity. Please open a new issue if are still encountering problems.

_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

+1 React Native 0.61.4

"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

+1 Using expo

how do we fix this? I am getting it also.

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

Please update the following components: ConfirmSignUp

expo-cli: 3.11.1
"expo": "^36.0.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
"aws-amplify": "^2.2.1",
"aws-amplify-react-native": "^2.2.3",

I am getting the same warning.

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

  • node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5864:19 in printWarning
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5892:25 in lowPriorityWarning
  • node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:6135:8 in ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings

I have the exact same issue as well when using Authenticator from aws-amplify-react-native without Expo. Here is my package.json:

  "dependencies": {
    "amazon-cognito-identity-js": "^3.2.2",
    "aws-amplify": "^2.2.2",
    "aws-amplify-react-native": "^3.2.0",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-gesture-handler": "^1.5.3",
    "react-native-reanimated": "^1.7.0",
    "react-native-screens": "^2.0.0-alpha.32",
    "react-native-vector-icons": "^6.6.0",
    "react-navigation": "^4.1.0",
    "react-navigation-tabs": "^2.7.0"
  },
Was this page helpful?
0 / 5 - 0 ratings

Related issues

simon998yang picture simon998yang  路  3Comments

TheRealRed7 picture TheRealRed7  路  3Comments

callmekatootie picture callmekatootie  路  3Comments

romainquellec picture romainquellec  路  3Comments

rygo6 picture rygo6  路  3Comments