react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

[V2] Malformed calls from JS: field sizes are different

Open Necromant1k opened this issue 8 years ago • 8 comments

Issue Description

Unable to pass props through passProps on route initialization.

I'm using WatermelonDB for offline support. And i should pass database property on initialization, but currently i'm having issues with it.

Here is route initialization

Navigation.setRoot({
    root: {
      options: {},
      stack: {
        children: [
          {
            component: {
              id: 'SplashPage',
              name: 'SplashPage',
              passProps: {
                database       // <--- It's always throws an error
              }
            },
          },
        ],
        options: {
          topBar: {
            visible: false,
            animate: false,
            drawBehind: true,
          },
        },
      },
    },
  });

Error i'm getting

image


Environment

  • React Native Navigation version: ^2.0.2538
  • React Native version: 0.56.0
  • Platform(s) (iOS, Android, or both?): iOS
  • Device info (Simulator/Device? OS version? Debug/Release?): Simulator

Necromant1k avatar Sep 14 '18 21:09 Necromant1k

I remember having issues passing MobX State Tree models to screens in v1 of RNN. I can't remember the exact error, but I had resorted to doing something like:

passProps: {
    getDatabase: () => database
}

It's not ideal by any means, but it's worth trying so you're not stuck for the time being.

wbercx avatar Sep 15 '18 03:09 wbercx

I believe this issue will be resolved once we stop passing props over the bridge. We already save options in js as they aren't serializable, we just need to omit them when processing options

https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/OptionsProcessor.ts#L35 https://github.com/wix/react-native-navigation/blob/v2/lib/src/commands/OptionsProcessor.ts#L45

guyca avatar Sep 16 '18 13:09 guyca

@Necromant1k btw can't you use React context to pass Database deep into the component tree?

radex avatar Sep 25 '18 14:09 radex

@radex Passing a model via passProps causes an issue with observed collections: Record ID was sent over the bridge, but it's not cached

...
passProps: {
  model: () => model
}
...

using above function works though. not sure if this is a bug in watermelondb or RNN, but took me forever searching issues on watermelondb and finally stumbled on to this thread.

Might be useful to add a note in the watermelondb docs about the above workaround. If I find time this week I could make a PR if you think it's appropriate

kerryaustin avatar Feb 20 '19 10:02 kerryaustin

It's happening for me on 0.59.8 too. Reason for this was that I was calling the native method with an object that contains a field with NaN value. SomeNativeModule.someMethod({number:NaN}) // crashed for me Adding a safe check resolved it for me. Ideally, I think it should not crash :( and handle these cases

vardaan avatar Jul 03 '19 10:07 vardaan

@vardaan please can you explain exactly how you fixed this please. That description was confusing for me

dihan avatar Jul 11 '19 10:07 dihan

@vardaan please can you explain exactly how you fixed this please. That description was confusing for me

@dihan you have just to check for NaN value. For example isNaN(myvalue). And if it's NaN just provide default value for example 0

Necromant1k avatar Jul 11 '19 13:07 Necromant1k

We did exactly what @Necromant1k said I m sorry for replying late

vardaan avatar Aug 07 '19 11:08 vardaan