React-native-navigation: [V2] Malformed calls from JS: field sizes are different

Created on 14 Sep 2018  路  8Comments  路  Source: wix/react-native-navigation

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
Android iOS acceptebug v2

All 8 comments

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.

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

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

@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

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 please can you explain exactly how you fixed this please. That description was confusing for me

@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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edcs picture edcs  路  3Comments

switchtrue picture switchtrue  路  3Comments

nbolender picture nbolender  路  3Comments

henrikra picture henrikra  路  3Comments

bdrobinson picture bdrobinson  路  3Comments