react-native-calendars icon indicating copy to clipboard operation
react-native-calendars copied to clipboard

Warning : Failed child context type: Invalid child context 'virtualizedCell.cellKey' of type 'number' supplied to 'CellRenderer', expected 'string'

Open sylvainbouxin opened this issue 8 years ago • 11 comments

Please make our job easier by filling this template out to completion. If you're requesting a feature instead of reporting a bug, please feel free to skip the Environment and Reproducible Demo sections.

Description

Since I upgraded from react-native 0.51 to 0.53, I get this warning in the Adenda: Warning : Failed child context type: Invalid child context 'virtualizedCell.cellKey' of type 'number' supplied to 'CellRenderer', expected 'string'

Expected Behavior

What action did you perform, and what did you expect to happen? I upgraded from react-native 0.51 to 0.53

Observed Behavior

What actually happened when you performed the above actions? the warning is poping.

If there's an error message, please paste the full terminal output and error message in this code block: No error, just a warning...

Warning: Failed child context type: Invalid child context virtualizedCell.cellKey of type number supplied to CellRenderer, expected string. in CellRenderer (at VirtualizedList.js:681) in RCTView (at View.js:71) in View (at ScrollView.js:726) in RCTScrollView (at ScrollView.js:820) in ScrollView (at VirtualizedList.js:1009) in VirtualizedList (at FlatList.js:640) in FlatList (at index.js:188) in ReactComp (at index.js:267) in RCTView (at View.js:71) in View (at index.js:375) in RCTView (at View.js:71) in View (at index.js:374) in AgendaView (at Calendar.js:96) in Calendar (created by Connect(Calendar)) in Connect(Calendar) (at Navigation.js:83) in Provider (at Navigation.js:82) in _class2 (at renderApplication.js:35) in RCTView (at View.js:71) in View (at AppContainer.js:102) in RCTView (at View.js:71) in View (at AppContainer.js:122) in AppContainer (at renderApplication.js:34)

Environment

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

Also specify:

  1. Phone/emulator/simulator & version:

This is hapenning for both iOS and Android. It seems that react-native is now expecting String keys in ListViews, but not sure how to address this issue.

sylvainbouxin avatar Feb 19 '18 19:02 sylvainbouxin

Same issue face.

hardy-android avatar Mar 08 '18 05:03 hardy-android

Seeing this as well. A strange update, seeing it in 0.54.0. It seems like common practice to use the index of the array as a key.

chrismllr avatar Mar 08 '18 17:03 chrismllr

Facing a similar issue in RN 0.54.1.

UPDATE: Just fixed the issue by converting the result from my key extractor to a string using the toString() method as follows: _keyExtractor = (item, index) => index.toString();. I hope this helps someone else.

cc: @sylvainbouxin @hardy-android @chrismllr

crim3hound avatar Mar 11 '18 16:03 crim3hound

Thx @anti-nerd, this helped me out.

Changed keyExtractor = (item) => item.id; to keyExtractor = (item) => `key-${item.id}`; and the warning disappeared.

donni106 avatar Mar 13 '18 19:03 donni106

@anti-nerd actually, updated to 0.54.2 and latest rn-calendars, and this seems to be fixed...

sylvainbouxin avatar Mar 13 '18 21:03 sylvainbouxin

updating both packages also worked for me !

maxaggedon avatar Mar 14 '18 14:03 maxaggedon

Another solution is change keyExtractor = (item) => item.id to keyExtractor = (item) => item.id.toString()

augustocbx avatar May 04 '18 19:05 augustocbx

I have the same issue,

i tried to convert my result to string by using : renderEvent={(event) => {event.title.toString()}}

but it doesn't work

AbdelkarimGhaouri avatar May 22 '18 13:05 AbdelkarimGhaouri

I have the same issue,

i tried to convert my result to string by using : renderEvent={(event) => {event.title.toString()}}

but it doesn't work

I believe you have to use it on the keyExtractor

levelingup avatar Jan 25 '20 16:01 levelingup

@donni106 Changed = keyExtractor = (item) => item.id; to= keyExtractor = {(item) => key-${item.id}} and the warning disappeared.

ArunDexbytes avatar Feb 03 '20 10:02 ArunDexbytes

keyExtractor={ (item, index) => index.toString() } Worked for me.Hope it will help others.

re-ali avatar Apr 10 '20 09:04 re-ali