nandorojo / moti

🐼 The React Native (+ Web) animation library, powered by Reanimated 3.
https://moti.fyi
MIT License
3.93k stars 122 forks source link

Any imported Moti components break in React Native because of a userAgent check used by framer-motion #352

Open avivash opened 2 weeks ago

avivash commented 2 weeks ago

Is there an existing issue for this?

Do you want this issue prioritized?

Current Behavior

When I import any Moti component into my react native app, I see this error that userAgent is undefined. I traced it back to the framer-motion library, which I didn't think was used on native?

image

Expected Behavior

I should be able to import components.

Steps To Reproduce

  1. add reanimated imports to my App.tsx
    import 'react-native-reanimated'
    import 'react-native-gesture-handler
  2. Import any Moti component into my app and I get the navigator.userAgent undefined error because of framer-motion

Versions

- Moti: 0.29.0
- Reanimated: 3.6.3
- React Native: 0.72.3

Screenshots

image

Reproduction

will add

avivash commented 2 weeks ago

I was able to get this working by polyfilling navigator.userAgent for now, but I wonder if there's a better way?

if (!global?.navigator?.userAgent) {
  global.navigator = {
    ...global.navigator,
    userAgent: 'React Native',
  }
}
nandorojo commented 2 weeks ago

might be a framer version issue

avivash commented 2 weeks ago

might be a framer version issue

thanks 👍🏼 i'll try to diagnose further