react-native
react-native copied to clipboard
TypeError: Cannot read property 'getItem' of undefined
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.
- Error is triggered when FlatList is used on any page
- 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:
========================= Screenshots
Ios
Android
Description
What are you passing as data to the flatlist.
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)}
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
Same issue here on RN 0.64.1. Using a FlatList even the example from the docs site fails with this error.
RN 0.66 the same issue.
RN 0.66.2/0.66.3 the same issue.
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 sorry, It's been so long. I forget how to fix it...
RN 0.70.6 the same issue.
Hi @jlm0 Is it fix in RN 0.71.0 ?
Is there any result...
This issue has been here for so long
@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.
@codewithmecoder Oops, I'm sorry An accident happened with my cached files. The issue is not there with React-Native version 0.71.3
The problem can be fixed by removing ['@babel/plugin-proposal-private-methods'], from babel.config.js. or using VirtualizedList instead of FlatList