Skip to content

TypeError: NativeModule.getConstants is not a function with React 0.76.2 #4554

@paulschreiber

Description

@paulschreiber

Current behaviour

After upgrading to Expo 52 and React Native 0.76.2, we see this error when running tests

TypeError: NativeModule.getConstants is not a function

Full run log: https://github.com/techmatters/terraso-mobile-client/actions/runs/11861325241/job/33058440974

Excerpt with stack trace:

TypeError: NativeModule.getConstants is not a function

      15 |  * along with this program. If not, see [https://www.gnu.org/licenses/.](https://www.gnu.org/licenses/)
      16 |  */
    > 17 | import {useRef} from 'react';
         |                              ^
      18 | import {Portal} from 'react-native-paper';
      19 | import {Provider} from 'react-redux';
      20 |

      at Object.getConstants (node_modules/react-native/src/private/specs/modules/NativeDeviceInfo.js:52:32)
      at Object.getConstants (node_modules/react-native/Libraries/Utilities/Dimensions.js:121:33)
      at Object.require (node_modules/react-native/Libraries/Utilities/PixelRatio.js:13:20)
      at Object.require (node_modules/react-native/Libraries/StyleSheet/StyleSheet.js:29:20)
      at Object.require [as StyleSheet] (node_modules/react-native/index.js:306:12)
      at Object.StyleSheet (node_modules/react-native-paper/lib/module/components/Portal/PortalHost.js:112:16)
      at Object.require (node_modules/react-native-paper/lib/module/components/Portal/Portal.js:3:1)
      at Object.require (jest/integration/utils.tsx:17:30)
      at Object.<anonymous> (__tests__/snapshot/LoginScreen-test.tsx:18:1)
      at asyncGeneratorStep (node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:17)
      at _next (node_modules/@babel/runtime/helpers/asyncToGenerator.js:17:9)

Expected behaviour

No errors. Tests run and pass.

How to reproduce?

npm run test with https://github.com/techmatters/terraso-mobile-client/tree/fix/expo52

What have you tried so far?

Your Environment

software version
react-native 0.76.2
react-native-paper 5.12.5
node 22.11.0
npm or yarn 10.9.0
expo sdk 52.0.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions