terrysahaidak / react-native-gallery-toolkit

Reanimated 2 powered gallery implementation
MIT License
662 stars 38 forks source link

Cannot make it work in a fresh project (RN 0.62.2): Object.values requires that input parameter not be null or undefined #10

Closed ferrannp closed 4 years ago

ferrannp commented 4 years ago

First of all thank you very much for this library you are creating. It looks really amazing and I think there is nothing better out there.

I got a problem when trying to make it work though and I am not sure if is because I am not using react-native: 0.63.x or I am doing something wrong.

The error I get is: Object.values requires that input parameter not be null or undefined.

image

Here is a repo: https://github.com/ferrannp/reanimated-gallery-example. It is a fresh app with react-native init using react-native: 0.62.x. The app code is a copy-paste of your example: https://github.com/ferrannp/reanimated-gallery-example/blob/master/App.js

terrysahaidak commented 4 years ago

Hi there. Sorry it took me so long to respond. The error seems to be related to the version won't f Reanimated you're using. Especially to the plugin. Also, make sure to clear metro's cache. Also it could happen if babel plugin is not working. Could you try this same example with newer version of Reanimated2 and RN?

ferrannp commented 4 years ago

Hey @terrysahaidak thanks for answering! I tried it in the same repo with "react-native-reanimated": "^2.0.0-alpha.4" (latest) and cleaning metro cache and I get the same error. I am trying with RN 0.62.2 because in the project I want to implement it we cannot update to 0.63.x just yet.

terrysahaidak commented 4 years ago

I see you're using your own build of the lib. Make sure to use reanimated's babel plugin for build with the same version as the version you're going to use in your app.

I will try to make sure it works on 0.62 as well.

terrysahaidak commented 4 years ago

also, RN can build TS files for you, so it's better to use the source code for now until I create a proper release.

terrysahaidak commented 4 years ago

Seems like there are some errors in the AppDelegate you've provided. I copy/pasted it from Reanimated Playground repo and now it crashes because of this error "Right side of an assignment cannot be restructured" in the js code which is executed on the UI thread (in worklet).

ferrannp commented 4 years ago

Hey @terrysahaidak. I updated the repo https://github.com/ferrannp/reanimated-gallery-example with:

  1. Installing the library directly from your repo latest commit "reanimated-gallery": "https://github.com/terrysahaidak/reanimated-gallery#7588abe43f64d021d77b0bfad583b301190e0b4a"
  2. I copied and paste your AppDelegate.mm with only this change from reanimated docs for 0.62.x:
( Additinal step for React Native 0.62.* ) Change initialization of TurboModuleManager
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
{
  _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge delegate:self];
  ...

Now the app is not crashing but when I click on an image, nothing happens (I cannot click anything else because it seems there is an overlay, but you cannot see the gallery).

Edit:

Oks, it looks like I removed _bridge_reanimated = bridge; by mistake. Now it works! 🎉 . Thanks for help!

Btw, when do you plan to make a release of this fantastic library? If you need help with some test/QA, let me know. Thank you!