Goglides Dev 🌱

Balkrishna Pandey
Balkrishna Pandey

Posted on

Resolving the "Class Private Methods are Not Enabled" Error in React Native

Recently, I encountered the following error, while I was doing this mobile app development using React Native.

node_modules/react-native/Libraries/Debugging/DebuggingOverlayRegistry.js: /Users/bkpandey/Documents/workspace/code/ReactNative-Meet-Flow/package/node_modules/react-native/Libraries/Debugging/DebuggingOverlayRegistry.js: Class private methods are not enabled. Please add `@babel/plugin-transform-private-methods` to your configuration.
  117 |   };
  118 |
> 119 |   #findLowestParentFromRegistryForInstance(
      |   ^
  120 |     instance: ReactNativeElement,
  121 |   ): ?DebuggingOverlayRegistrySubscriberProtocol {
  122 |     let iterator: ?ReadOnlyElement = instance;
Enter fullscreen mode Exit fullscreen mode

To resolve this error, you need to update your Babel configuration to include the @babel/plugin-transform-private-methods plugin. I added @babel/plugin-transform-private-methods plugin to Babel configuration file, babel.config.js. Updated configuration should look like this:

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    'react-native-reanimated/plugin',
    ['@babel/plugin-transform-private-methods', { loose: true }]
  ],
};
Enter fullscreen mode Exit fullscreen mode

Top comments (0)