React-native-calendars: Warning: componentWillReceiveProps has been renamed, and is not recommended for use

Created on 12 Dec 2019  路  16Comments  路  Source: wix/react-native-calendars

Description

Update react native expo to SDK 35.0.0. Calendar throws a warning.

Expected Behavior

No warning.

Observed Behavior

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: Calendar, CalendarList

Environment

Please run these commands in the project folder and fill in their results:

Also specify:

  1. Phone/emulator/simulator & version: iPhone 8, iOS 12.2

Reproducible Demo

Just update to newest version of react-native (0.61) and expo (SDK 35.0.0) [if expo is used]. Then simply import CalendarList and render it, and warning will be shown.

FIX

Most helpful comment

@Itayp1 @jet2go Do you get this warning with versions later than 1.226.0?

I m getting error in 1.261.0

All 16 comments

I am also experiencing this, I know this package is looking for maintainers, any news on that front? Trying to get an idea for when this can be fixed.

Experiencing this too. Not only for Calendar but also for Agenda, 2 warnings are thrown - componentWillMount and componentWillReceiveProps

Screenshot 2019-12-16 at 01 10 31
Screenshot 2019-12-16 at 01 10 55

This is very annoying issue. I don`t think that this will take much time to solve this problem, so please update it asap.

I've caught the same warning
[email protected]
[email protected]
please update it

I am also having same issue. If maintainer could change that those code into this one.

static getDerivedStateFromProps(nextProps, prevState){
const current = parseDate(nextProps.current);
if (current && current.toString('yyyy MM') !== prevState.currentMonth.toString('yyyy MM')) {
return {
currentMonth:current.clone()
}
}
return prevState;
}

@AmroShohoud We're on it, there PRs in this matter that we're reviewing.

i am having the same issue

Same here!

@Itayp1 @jet2go Do you get this warning with versions later than 1.226.0?

I'm using react-native-modal-datetime-picker but getting the same error shown above.

@jet2go What is react-native-modal-datetime-picker has to do with this issue? The two libraries are not related. I was asking about react-native-calendars' version as we renamed these methods on version 1.226.0.

@Itayp1 @jet2go Do you get this warning with versions later than 1.226.0?

I m getting error in 1.261.0

Same here 鈽濓笍

I can't reproduce the issue. We renamed all of these methods... Can someone please send me a screenshot of the full warning? Does it show only on Expo apps?

Same issue with latest version.
"react-native-calendars": "^1.264.0",
Any update?

We renamed all our lifecycles, please reinstall your modules.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

filippoitaliano picture filippoitaliano  路  3Comments

chapeljuice picture chapeljuice  路  3Comments

sommeshEwall picture sommeshEwall  路  3Comments

nickitatkach picture nickitatkach  路  4Comments

MrAlekhin picture MrAlekhin  路  4Comments