software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
9.03k stars 1.3k forks source link

TypeError: window.matchMedia is not a function #5921

Open zajecvolk opened 6 months ago

zajecvolk commented 6 months ago

Description

Hi!. When I try to run a development build using the npx expo run:ios command and I use a component that uses react-native-reanimated I receive an error:

ERROR TypeError: window.matchMedia is not a function (it is undefined), js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if:

  • Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
  • A module failed to load due to an error and AppRegistry.registerComponent wasn't called., js engine: hermes

Do you have any idea what I'm doing wrong?

I tried changing the reanimated versions but it didn't help. I have the impression that the error appeared suddenly because there was no problem with this version before.

I have never had such problems using Reanimated before.

Steps to reproduce

  1. Run npx expo run:ios
  2. Import/use component using react-native-reanimated.

Snack or a link to a repository

https://github.com/software-mansion/react-native-reanimated

Reanimated version

3.6.2

React Native version

0.73.5

Platforms

Android, iOS

JavaScript runtime

Hermes

Workflow

Expo Dev Client

Architecture

None

Build type

Debug app & dev bundle

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 6 months ago

Hey! πŸ‘‹

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

szydlovsky commented 6 months ago

Hello @zajecvolk πŸ‘‹ We always encourage bumping Reanimated to the newest versions - currently stable one is 3.8.1. Apart from that I would recommend to make a all-caches reset using git clean -xdf in repo root - it deletes all untracked files being node_modules, Pods, etc.. When done with that, the Pods should now be installed by running bundle install && bundle exec pod install. Let me know if anything changes for you!

zajecvolk commented 6 months ago

Hello @zajecvolk πŸ‘‹ We always encourage bumping Reanimated to the newest versions - currently stable one is 3.8.1. Apart from that I would recommend to make a all-caches reset using git clean -xdf in repo root - it deletes all untracked files being node_modules, Pods, etc.. When done with that, the Pods should now be installed by running bundle install && bundle exec pod install. Let me know if anything changes for you!

I updated Reanimated but it didn't help. Components that use Reanimated don't work even in storybook.

Zrzut ekranu 2024-05-9 o 15 44 56