Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatlist render error: Cannot read property 'getItem' of undefined #36828

Closed
salahbm opened this issue Apr 6, 2023 · 45 comments
Closed

Flatlist render error: Cannot read property 'getItem' of undefined #36828

salahbm opened this issue Apr 6, 2023 · 45 comments
Labels
Component: FlatList Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue.

Comments

@salahbm
Copy link

salahbm commented Apr 6, 2023

Description

I have been working on project which has several flatlists, which are causing problem suddenly. All flatlists that I have shows same issue dispite they were working previously. To add, auto refreshing also stopped working I dont know they are related to each other or not.

React Native Version

0.71.3

Output of npx react-native info

System:
OS: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i3-10105 CPU @ 3.70GHz
Memory: 5.21 GB / 15.87 GB
Binaries:
Node: 18.15.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 9.5.0 - C:\Program Files\nodejs\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 28, 31, 33
Build Tools: 28.0.3, 30.0.3, 31.0.0, 33.0.0
System Images: android-28 | Google APIs Intel x86 Atom, android-31 | Intel x86 Atom_64, android-31 | Google Play Intel x86 Atom_64, android-33 | Google APIs Intel x86_64 Atom
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-213.7172.25.2113.9123335
Visual Studio: Not Found
Languages:
Java: 11.0.18
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.3 => 0.71.3
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

Steps to reproduce:

Open the project and navigate to the screen where the flatlists are being used.
Observe that all the flatlists are not rendering and showing an error.
Check the console for any error messages related to the flatlists.
Look for the specific error message "Cannot read property 'getItem' of undefined".
Verify that this error is being displayed for all the flatlists on the screen.
Check if the code for the flatlists has been modified recently or if any libraries have been updated.
Verify that the data source for the flatlists is correctly defined and passed as props.
Make sure that the flatlist component is imported and rendered properly in the code.
Check if any other component or library is conflicting with the flatlists.
Provide any additional information that might be helpful for developers to identify and fix the issue.
Expected outcome:
The flatlists should render without any errors.

Actual outcome:
The flatlists are not rendering and showing the error message "Cannot read property 'getItem' of undefined".

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

// CODE IS GIVEN BELOW IS EXAMPLE WHICH WORKS ON BRAND NEW PROJECT BUT NOT IN THE CURRENTLY USED ONE

import React, {useState} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
Platform,
View,
FlatList,
} from 'react-native';
import {COLORS} from '../constants/theme';
const DATA = [
{id: '1', title: 'Item 1'},
{id: '2', title: 'Item 2'},
{id: '3', title: 'Item 3'},
{id: '4', title: 'Item 4'},
{id: '5', title: 'Item 5'},
{id: '6', title: 'Item 6'},
{id: '7', title: 'Item 7'},
];

const Item = ({title}) => (

{title}

);
const Settings = () => {
const [selectedId, setSelectedId] = useState(null);

const renderItem = ({item}) => ;

return (

<FlatList
horizontal
showsHorizontalScrollIndicator={false}
data={DATA}
renderItem={renderItem}
keyExtractor={item => item.id}
extraData={selectedId}
/>

);
};

const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 50,
},
item: {
backgroundColor: COLORS.primary,
padding: 5,
borderRadius: 20,
marginHorizontal: 5,
height: 50,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontSize: 22,
color: 'white',
},
});

export default Settings;

@cortinico
Copy link
Contributor

// CODE IS GIVEN BELOW IS EXAMPLE WHICH WORKS ON BRAND NEW PROJECT BUT NOT IN THE CURRENTLY USED ONE

We would need a reproducer to investigate this further sadly.

@cortinico cortinico added the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label Apr 6, 2023
@github-actions
Copy link

github-actions bot commented Apr 6, 2023

⚠️ Missing Reproducible Example
ℹ️ It looks like your issue is missing a reproducible example. Please provide a Snack or a repository that demonstrates the issue you are reporting in a minimal, complete, and reproducible manner.

@chizhkov422
Copy link

chizhkov422 commented Apr 7, 2023

Got the same error, only on android, any solution?

@salahbm
Copy link
Author

salahbm commented Apr 8, 2023

r

not yet, been searching for a week already

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Apr 8, 2023
@salahbm
Copy link
Author

salahbm commented Apr 8, 2023

sue you are re

Hello, thanks for yout reply. Here I have created the sample repo which is exactly same as my project, but it is working on new project. LINK: github repository. Thanks

@NickGerleman
Copy link
Contributor

This issue is not actionable without a repro or at least a callstack.

@chizhkov422
Copy link

TypeError: Cannot read property 'getItem' of undefined

This error is located at:
in FlatList (created by ChangeNetwork)
in RNCSafeAreaView
in Unknown (created by ChangeNetwork)
in RCTView (created by View)
in View (created by ChangeNetwork)
in ChangeNetwork (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by SceneView)
in RCTView (created by View)
in View (created by DebugContainer)
in DebugContainer (created by MaybeNestedStack)
in MaybeNestedStack (created by SceneView)
in RCTView (created by View)
in View (created by SceneView)
in RNSScreen (created by AnimatedComponent)
in AnimatedComponent
in AnimatedComponentWrapper (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by SceneView)
in SceneView (created by NativeStackViewInner)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by ScreenStack)
in RNSScreenStack (created by ScreenStack)
in ScreenStack (created by NativeStackViewInner)
in NativeStackViewInner (created by NativeStackView)
in RCTView (created by View)
in View (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by NativeStackView)
in NativeStackView (created by NativeStackNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by NativeStackNavigator)
in NativeStackNavigator (created by HomeNavigation)
in HomeNavigation (created by SceneView)
in StaticContainer
in EnsureSingleNavigator (created by SceneView)
in SceneView (created by SceneView)
in RCTView (created by View)
in View (created by DebugContainer)
in DebugContainer (created by MaybeNestedStack)
in MaybeNestedStack (created by SceneView)
in RCTView (created by View)
in View (created by SceneView)
in RNSScreen (created by AnimatedComponent)
in AnimatedComponent
in AnimatedComponentWrapper (created by InnerScreen)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by InnerScreen)
in InnerScreen (created by Screen)
in Screen (created by SceneView)
in SceneView (created by NativeStackViewInner)
in Suspender (created by Freeze)
in Suspense (created by Freeze)
in Freeze (created by DelayedFreeze)
in DelayedFreeze (created by ScreenStack)
in RNSScreenStack (created by ScreenStack)
in ScreenStack (created by NativeStackViewInner)
in NativeStackViewInner (created by NativeStackView)
in RCTView (created by View)
in View (created by SafeAreaInsetsContext)
in SafeAreaProviderCompat (created by NativeStackView)
in NativeStackView (created by NativeStackNavigator)
in PreventRemoveProvider (created by NavigationContent)
in NavigationContent
in Unknown (created by NativeStackNavigator)
in NativeStackNavigator (created by RootNavigation)
in PortalProviderComponent (created by BottomSheetModalProviderWrapper)
in BottomSheetModalProviderWrapper (created by RootNavigation)
in EnsureSingleNavigator
in BaseNavigationContainer
in ThemeProvider
in NavigationContainerInner (created by RootNavigation)
in RNCSafeAreaView
in Unknown (created by RootNavigation)
in RootNavigation (created by App)
in RCTView (created by View)
in View (created by KeyboardAvoidingView)
in KeyboardAvoidingView (created by App)
in RCTView (created by View)
in View (created by Pressable)
in Pressable (created by Pressable)
in SdkContextProvider (created by App)
in PersistGate (created by App)
in Provider (created by App)
in RNCSafeAreaProvider (created by SafeAreaProvider)
in SafeAreaProvider (created by App)
in RNGestureHandlerRootView (created by GestureHandlerRootView)
in GestureHandlerRootView (created by App)
in App
in RCTView (created by View)
in View (created by AppContainer)
in RCTView (created by View)
in View (created by AppContainer)
in AppContainer
in ChainGates(RootComponent), js engine: hermes

@chizhkov422
Copy link

image

image

@chizhkov422
Copy link

Maybe this will help solve the problem

@NickGerleman
Copy link
Contributor

So, the undefined bit here looks to be "this.props", which is derived directly from the input of the components constructor.

this._checkProps(this.props);

To continue figuring this out, I would attach a debugger to the FlatList constructor and follow the values. It seems very unlikely that this issue is in FlatList, but there could maybe be other environment factors.

@chizhkov422
Copy link

chizhkov422 commented Apr 8, 2023

<FlatList data={[]} renderItem={() => <></>} />

I tried using without the extra parameters in App.ts, but the problem remained. The error is only on Android, everything is fine with iOS.

@chizhkov422
Copy link

chizhkov422 commented Apr 8, 2023

I found the problem. After removing this code from babel.config.js and removing @babel/plugin-proposal-private-methods, everything is fine.
[ '@babel/plugin-proposal-private-methods', { loose: true, }, ],

@salahbm
Copy link
Author

salahbm commented Apr 8, 2023

Yeah, I have tries this previously as well, but didnt help .... (((

@salahbm
Copy link
Author

salahbm commented Apr 8, 2023

Thanks to @chizhkov422 I have checked my babel.config.js one more time, and removerd

"plugins": ["@babel/plugin-proposal-class-properties"]

which made it work again. Thanks one more time

@salahbm salahbm closed this as completed Apr 8, 2023
@victorLee11
Copy link

I found the problem. After removing this code from babel.config.js and removing @babel/plugin-proposal-private-methods, everything is fine. [ '@babel/plugin-proposal-private-methods', { loose: true, }, ],

good job

@artemis-prime
Copy link

Since this is a common enough plugin (as is class-properties), I think this should be better documented and possibly fixed in the RN codebase. Please re-open!

@infoani92
Copy link

I found the problem. After removing this code from babel.config.js and removing @babel/plugin-proposal-private-methods, everything is fine. [ '@babel/plugin-proposal-private-methods', { loose: true, }, ],

yes it's working when I remove I got another error while npm test

jest-runner/build/index.js: Class private methods are not enabled. Please add @babel/plugin-transform-private-methods to your configuration

Does anyone know how this will fix?

@Roman-Hladilka
Copy link

@infoani92 instead of removing @babel/plugin-proposal-private-methods you could install to devDependancies and add in babel plugins before @babel/plugin-proposal-private-methods (it is important) this plugin: @babel/plugin-transform-flow-strip-types. It should help

@lavarajallu
Copy link

I found the problem. After removing this code from babel.config.js and removing @babel/plugin-proposal-private-methods, everything is fine. [ '@babel/plugin-proposal-private-methods', { loose: true, }, ],

Thank you @chizhkov422 you saved my time

@xavcochran
Copy link

Im still having the same issue. Adding this.props = props; under super(props); in the construction around L412-L420 in node_modules/react-native/Libraries/Lists/FlatList.js fixed the issue until I tried to use EAS to compile my app to put in on TestFlight.

ive removed the suggested parts of my babel.config.js above but the error still persits. Completely stuck!

@mattgle
Copy link

mattgle commented Jun 12, 2023

@infoani92 instead of removing @babel/plugin-proposal-private-methods you could install to devDependancies and add in babel plugins before @babel/plugin-proposal-private-methods (it is important) this plugin: @babel/plugin-transform-flow-strip-types. It should help

Im not sure if I'm following you, you mean to do this right?

Delete the following lines from babel.config.js

 '@babel/plugin-proposal-class-properties',
 '@babel/plugin-proposal-private-methods',

and then run

yarn add @babel/plugin-proposal-private-methods --dev
yarn add @babel/plugin-transform-flow-strip-types --dev

@lavarajallu
Copy link

lavarajallu commented Jun 13, 2023 via email

@aaronzyf
Copy link

@mattgle I meant that you don't need nothing to remove from babel.config.js, as '@babel/plugin-proposal-private-methods' is needed by jest. You need to install @babel/plugin-transform-flow-strip-types yarn add -D @babel/plugin-transform-flow-strip-types or npm install @babel/plugin-transform-flow-strip-types --save-dev and add it to babel.config.js before @babel/plugin-proposal-private-methods and other plugins. So your babel.config.js plugins will look like this plugins: [ ..... '@babel/plugin-transform-flow-strip-types', '@babel/plugin-proposal-class-properties' '@babel/plugin-proposal-private-methods', ..... ],

cool , it's works for me

@ayushkumarbhadani-sameta
Copy link

ayushkumarbhadani-sameta commented Nov 17, 2023

Guys, I'm also getting this same issue in the Flatlist from today morning.
I tried rolling back my project to few days back and deleted the node-modules, .expo directory and package-lock.json and did an npm cache clean --force before npm i again but the problem didn't solved.

Here is what it looks like:

Here is what my rolled back version of babel.config.js looks like:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      'expo-router/babel',
      'nativewind/babel',
      'react-native-reanimated/plugin',
    ],
  };
};

Here is what my package.json looks like:

{
  "name": "project-name",
  "version": "1.0.0",
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "^49.0.16",
    "expo-checkbox": "~2.4.0",
    "expo-clipboard": "~4.3.1",
    "expo-constants": "^14.4.2",
    "expo-document-picker": "~11.5.4",
    "expo-linear-gradient": "~12.3.0",
    "expo-linking": "~5.0.2",
    "expo-router": "^2.0.10",
    "expo-status-bar": "~1.6.0",
    "formik": "^2.4.5",
    "nativewind": "^2.0.11",
    "react": "^18.2.0",
    "react-native": "0.72.6",
    "react-native-element-dropdown": "^2.10.0",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-modal": "^13.0.1",
    "react-native-qrcode-svg": "^6.2.0",
    "react-native-reanimated": "~3.3.0",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-root-toast": "^3.5.1",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-svg": "13.9.0",
    "react-native-vector-icons": "^10.0.1",
    "yup": "^1.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.23.2",
    "@react-native-community/datetimepicker": "7.2.0",
    "@tailwindcss/typography": "^0.5.10",
    "@tsconfig/react-native": "^3.0.2",
    "@types/jest": "^29.5.7",
    "@types/react": "^18.2.34",
    "@types/react-native-vector-icons": "^6.4.16",
    "@types/react-test-renderer": "^18.0.5",
    "tailwindcss": "3.3.2",
    "typescript": "^5.2.2"
  },
  "private": true
}

Please note that, this error was not there before when I committed these changes.

Can anyone please help me out.

@ayushkumarbhadani-sameta

Guys, I'm also getting this same issue in the Flatlist from today morning. I tried rolling back my project to few days back and deleted the node-modules, .expo directory and package-lock.json and did an npm cache clean --force before npm i again but the problem didn't solved.

Here is what it looks like:

Here is what my rolled back version of babel.config.js looks like:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      'expo-router/babel',
      'nativewind/babel',
      'react-native-reanimated/plugin',
    ],
  };
};

Here is what my package.json looks like:

{
  "name": "project-name",
  "version": "1.0.0",
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "^49.0.16",
    "expo-checkbox": "~2.4.0",
    "expo-clipboard": "~4.3.1",
    "expo-constants": "^14.4.2",
    "expo-document-picker": "~11.5.4",
    "expo-linear-gradient": "~12.3.0",
    "expo-linking": "~5.0.2",
    "expo-router": "^2.0.10",
    "expo-status-bar": "~1.6.0",
    "formik": "^2.4.5",
    "nativewind": "^2.0.11",
    "react": "^18.2.0",
    "react-native": "0.72.6",
    "react-native-element-dropdown": "^2.10.0",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-modal": "^13.0.1",
    "react-native-qrcode-svg": "^6.2.0",
    "react-native-reanimated": "~3.3.0",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-root-toast": "^3.5.1",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-svg": "13.9.0",
    "react-native-vector-icons": "^10.0.1",
    "yup": "^1.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.23.2",
    "@react-native-community/datetimepicker": "7.2.0",
    "@tailwindcss/typography": "^0.5.10",
    "@tsconfig/react-native": "^3.0.2",
    "@types/jest": "^29.5.7",
    "@types/react": "^18.2.34",
    "@types/react-native-vector-icons": "^6.4.16",
    "@types/react-test-renderer": "^18.0.5",
    "tailwindcss": "3.3.2",
    "typescript": "^5.2.2"
  },
  "private": true
}

Please note that, this error was not there before when I committed these changes.

Can anyone please help me out.

Guys, I solved this issue.
It was just expo catch that was giving problem. I used npx expo . -c on the root of the project.

@aamirbinabd
Copy link

Guys, I'm also getting this same issue in the Flatlist from today morning. I tried rolling back my project to few days back and deleted the node-modules, .expo directory and package-lock.json and did an npm cache clean --force before npm i again but the problem didn't solved.
Here is what it looks like:
Here is what my rolled back version of babel.config.js looks like:

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: [
      'expo-router/babel',
      'nativewind/babel',
      'react-native-reanimated/plugin',
    ],
  };
};

Here is what my package.json looks like:

{
  "name": "project-name",
  "version": "1.0.0",
  "main": "expo-router/entry",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "expo": "^49.0.16",
    "expo-checkbox": "~2.4.0",
    "expo-clipboard": "~4.3.1",
    "expo-constants": "^14.4.2",
    "expo-document-picker": "~11.5.4",
    "expo-linear-gradient": "~12.3.0",
    "expo-linking": "~5.0.2",
    "expo-router": "^2.0.10",
    "expo-status-bar": "~1.6.0",
    "formik": "^2.4.5",
    "nativewind": "^2.0.11",
    "react": "^18.2.0",
    "react-native": "0.72.6",
    "react-native-element-dropdown": "^2.10.0",
    "react-native-gesture-handler": "~2.12.0",
    "react-native-modal": "^13.0.1",
    "react-native-qrcode-svg": "^6.2.0",
    "react-native-reanimated": "~3.3.0",
    "react-native-reanimated-carousel": "^3.5.1",
    "react-native-root-toast": "^3.5.1",
    "react-native-safe-area-context": "4.6.3",
    "react-native-screens": "~3.22.0",
    "react-native-svg": "13.9.0",
    "react-native-vector-icons": "^10.0.1",
    "yup": "^1.3.2"
  },
  "devDependencies": {
    "@babel/core": "^7.23.2",
    "@react-native-community/datetimepicker": "7.2.0",
    "@tailwindcss/typography": "^0.5.10",
    "@tsconfig/react-native": "^3.0.2",
    "@types/jest": "^29.5.7",
    "@types/react": "^18.2.34",
    "@types/react-native-vector-icons": "^6.4.16",
    "@types/react-test-renderer": "^18.0.5",
    "tailwindcss": "3.3.2",
    "typescript": "^5.2.2"
  },
  "private": true
}

Please note that, this error was not there before when I committed these changes.
Can anyone please help me out.

Guys, I solved this issue. It was just expo catch that was giving problem. I used npx expo . -c on the root of the project.

This helped me as well. Ran npx expo . -c and the error was gone.

@ctapang
Copy link

ctapang commented Jan 26, 2024

This shouldn't have been closed. The bug is still there. I agree with 0xFadedd:
#36828 (comment)

The local object this.props is not initialized. The fix is simply to initialize it as 0xFadedd lucidly explained last year.

@ctapang
Copy link

ctapang commented Jan 27, 2024

This is another comment with the same simple fix as proposed by 0xFadedd :
#36828 (comment)

@abpbackup
Copy link

@infoani92 instead of removing @babel/plugin-proposal-private-methods you could install to devDependancies and add in babel plugins before @babel/plugin-proposal-private-methods (it is important) this plugin: @babel/plugin-transform-flow-strip-types. It should help

This worked for me and didn't break the tests

@sovetski
Copy link

I have the same issue here, not resolved by others suggestions

@Kyle772
Copy link

Kyle772 commented Feb 14, 2024

 this.props = props;

I solved it, following this step by adding the props in the constructor alterando este construtor emnode_modules/react-native/Libraries/Lists/FlatList.js

constructor(props: Props) { super(props); this._checkProps(this.props); if (this.props.viewabilityConfigCallbackPairs) { this._virtualizedListPairs = // rest of code } para isso (adicionando this.props = props;)

constructor(props: Props) { super(props); this.props = props; this._checkProps(this.props); if (this.props.viewabilityConfigCallbackPairs) { this._virtualizedListPairs = // rest of code }

This fixed my problem after trying many of the other suggestions. Thank you

@zainkhas
Copy link

@mattgle I meant that you don't need nothing to remove from babel.config.js, as '@babel/plugin-proposal-private-methods' is needed by jest. You need to install @babel/plugin-transform-flow-strip-types yarn add -D @babel/plugin-transform-flow-strip-types or npm install @babel/plugin-transform-flow-strip-types --save-dev and add it to babel.config.js before @babel/plugin-proposal-private-methods and other plugins. So your babel.config.js plugins will look like this plugins: [ ..... '@babel/plugin-transform-flow-strip-types', '@babel/plugin-proposal-class-properties' '@babel/plugin-proposal-private-methods', ..... ],

Thanks, this works for expo:

/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
    plugins: ['@babel/plugin-transform-flow-strip-types', ['@babel/plugin-transform-private-methods', { loose: true }]],
  };
};

then

npx expo start -c

Thank you. This worked for me too in expo.

Ashoat added a commit to CommE2E/comm that referenced this issue Apr 2, 2024
Summary:
This solves [ENG-7635](https://linear.app/comm/issue/ENG-7635/cannot-read-property-getitem-of-undefined), at least temporarily. It looks like it's [this GitHub issue](facebook/react-native#36828), first introduced by [this change](d543b13#diff-6cbb99cac6ea458360d1a029240d3d962e43c86756958d30bfe0434166be073a).

People on the GitHub issue have several suggestions:

1. This change
2. Removing `@babel/plugin-transform-private-methods`, which we could consider if we remove the private method uses in the transitive dependency that necessitates its introduction initially
3. Adding a babel plugin somewhere that strips Flow types. I'll consider this one as I continue investigating

Test Plan: Confirm that the issue goes away after resetting the Metro cache (`yarn dev -c`) and refreshing the app

Reviewers: ginsu, will, atul

Subscribers:
Ashoat added a commit to CommE2E/comm that referenced this issue Apr 2, 2024
Summary:
This solves [ENG-7635](https://linear.app/comm/issue/ENG-7635/cannot-read-property-getitem-of-undefined), at least temporarily. It looks like it's [this GitHub issue](facebook/react-native#36828), first introduced by [this change](d543b13#diff-6cbb99cac6ea458360d1a029240d3d962e43c86756958d30bfe0434166be073a).

People on the GitHub issue have several suggestions:

1. This change
2. Removing `@babel/plugin-transform-private-methods`, which we could consider if we remove the private method uses in the transitive dependency that necessitates its introduction initially
3. Adding a babel plugin somewhere that strips Flow types. I'll consider this one as I continue investigating

Test Plan: Confirm that the issue goes away after resetting the Metro cache (`yarn dev -c`) and refreshing the app

Reviewers: ginsu, will, atul

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D11527
Ashoat added a commit to CommE2E/comm that referenced this issue Apr 2, 2024
Summary:
This solves [ENG-7635](https://linear.app/comm/issue/ENG-7635/cannot-read-property-getitem-of-undefined), at least temporarily. It looks like it's [this GitHub issue](facebook/react-native#36828), first introduced by [this change](d543b13#diff-6cbb99cac6ea458360d1a029240d3d962e43c86756958d30bfe0434166be073a).

People on the GitHub issue have several suggestions:

1. This change
2. Removing `@babel/plugin-transform-private-methods`, which we could consider if we remove the private method uses in the transitive dependency that necessitates its introduction initially
3. Adding a babel plugin somewhere that strips Flow types. I'll consider this one as I continue investigating

Test Plan: Confirm that the issue goes away after resetting the Metro cache (`yarn dev -c`) and refreshing the app

Reviewers: ginsu, will, atul

Reviewed By: ginsu

Subscribers: tomek

Differential Revision: https://phab.comm.dev/D11527
@aryan127
Copy link

@mattgle I meant that you don't need nothing to remove from babel.config.js, as '@babel/plugin-proposal-private-methods' is needed by jest. You need to install @babel/plugin-transform-flow-strip-types yarn add -D @babel/plugin-transform-flow-strip-types or npm install @babel/plugin-transform-flow-strip-types --save-dev and add it to babel.config.js before @babel/plugin-proposal-private-methods and other plugins. So your babel.config.js plugins will look like this plugins: [ ..... '@babel/plugin-transform-flow-strip-types', '@babel/plugin-proposal-class-properties' '@babel/plugin-proposal-private-methods', ..... ],

Broo just thank you, you just save me you absolute genius person. Thank you brother have a great day.

@JoaoPauloXD
Copy link

I found the problem. After removing this code from babel.config.js and removing @babel/plugin-proposal-private-methods, everything is fine. [ '@babel/plugin-proposal-private-methods', { loose: true, }, ],

thanks, man, I remove these lines of my babel.config.js:

["@babel/plugin-transform-private-methods", { loose: true }],
["@babel/plugin-transform-class-properties", { loose: true }],
["@babel/plugin-transform-private-property-in-object", { loose: true }],

@HoaiHuynh
Copy link

By removing @babel/plugin-transform-private-methods, I solved this bug, but it created another bug when I ran test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: FlatList Needs: Attention Issues where the author has responded to feedback. Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue.
Projects
None yet
Development

No branches or pull requests