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

TypeError: Cannot read property 'getItem' of undefined

Open iababio opened this issue 3 years ago • 9 comments

Uncaught TypeError: Cannot read property 'getItem' of undefined at FlatList._checkProps (FlatList.js:452) at new FlatList (FlatList.js:396) at constructClassInstance (ReactNativeRenderer-dev.js:7726) at updateClassComponent (ReactNativeRenderer-dev.js:12729) at beginWork (ReactNativeRenderer-dev.js:14756) at Object.invokeGuardedCallbackProd (ReactNativeRenderer-dev.js:93) at invokeGuardedCallback (ReactNativeRenderer-dev.js:318) at beginWork$1 (ReactNativeRenderer-dev.js:19820) at performUnitOfWork (ReactNativeRenderer-dev.js:18563) at workLoopSync (ReactNativeRenderer-dev.js:18499)

React Native version:

Run react-native info in your terminal and copy the results here.

===================== info Fetching system and libraries information... System: OS: macOS 11.2.3 CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz Memory: 1.71 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.7.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.6.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: ^17.0.2 => 17.0.2 react-native: ^0.64.0 => 0.64.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

====================================

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Error is triggered when FlatList is used on any page
  2. VirstualList does not trigger this error

=================================

Expected Results

Describe what you expected to happen. To run the below list of data

children: Array(15) 0: {index: 0, name: "Afghanistan", code: "AF", states: Array(34)} 1: {name: "Albania", code: "AL", states: Array(12)} 2: {index: 2, name: "Algeria", code: "DZ", states: Array(48)} 3: {index: 3, name: "American Samoa", code: "AS"} 4: {index: 4, name: "Andorra", code: "AD", states: Array(7)} 5: {index: 5, name: "Angola", code: "AO", states: Array(18)}

===========================

Snack, code example, screenshot, or link to a repository:

{props?.list?.length ? ( { return renderView(item, index) }} keyExtractor={(item) => item.group} /> ) : null}

========================= Screenshots

Ios

error

Android

error-android

Description

iababio avatar May 14 '21 06:05 iababio

What are you passing as data to the flatlist.

sanu23kumar avatar May 17 '21 23:05 sanu23kumar

What are you passing as data to the flatlist.

children: Array(15) 0: {index: 0, name: "Afghanistan", code: "AF", states: Array(34)} 1: {name: "Albania", code: "AL", states: Array(12)} 2: {index: 2, name: "Algeria", code: "DZ", states: Array(48)} 3: {index: 3, name: "American Samoa", code: "AS"} 4: {index: 4, name: "Andorra", code: "AD", states: Array(7)} 5: {index: 5, name: "Angola", code: "AO", states: Array(18)}

iababio avatar May 30 '21 05:05 iababio

Pretty the same error. Try few libraries which use FlatList (for example react-native-autocomplete-input), then I try use an example from original Rn docs https://reactnative.dev/docs/flatlist Get same error with getItem I use 0.64.0 and get this problem. Downgrading to 63.2 help me and fix this error. Trying new 0.65 version (release candidate) also show this error

andreydos avatar Jun 10 '21 12:06 andreydos

Same issue here on RN 0.64.1. Using a FlatList even the example from the docs site fails with this error.

gtfunes avatar Aug 02 '21 14:08 gtfunes

RN 0.66 the same issue.

rusakovic avatar Oct 12 '21 21:10 rusakovic

RN 0.66.2/0.66.3 the same issue.

SolidZORO avatar Nov 12 '21 08:11 SolidZORO

Did you all find a solution or the source of the problem? I am having the same issue with RN 0.70.2. True with libraries using FlatList or just flat out placing a basic Flatlist on any page with placeholder number array data. A stackoverflow said the problem was with Babels private methods plugin (which i removed) and still the same issue.@SolidZORO @gtfunes @andreydos @rusakovic @melch-inno

jlm0 avatar Dec 19 '22 16:12 jlm0

@jlm0 sorry, It's been so long. I forget how to fix it...

SolidZORO avatar Dec 20 '22 03:12 SolidZORO

RN 0.70.6 the same issue.

codewithmecoder avatar Jan 11 '23 05:01 codewithmecoder

Hi @jlm0 Is it fix in RN 0.71.0 ?

codewithmecoder avatar Jan 18 '23 15:01 codewithmecoder

Is there any result...

Emptyuu avatar Jan 19 '23 13:01 Emptyuu

This issue has been here for so long

codewithmecoder avatar Jan 20 '23 01:01 codewithmecoder

@codewithmecoder the issue is still being present in 0.71.3 I'm on my way to check what's going wrong with the piece of FlatList code.

borvanov avatar Feb 22 '23 16:02 borvanov

@codewithmecoder Oops, I'm sorry An accident happened with my cached files. The issue is not there with React-Native version 0.71.3

borvanov avatar Feb 22 '23 17:02 borvanov

The problem can be fixed by removing ['@babel/plugin-proposal-private-methods'], from babel.config.js. or using VirtualizedList instead of FlatList

george-popescu avatar Oct 31 '23 07:10 george-popescu