Error : "Malformed class from JS: field sizes are different", while using CardItem component
I have gone through these following points
- [X] Check latest documentation: https://docs.nativebase.io/
- [X] Check for existing open/closed issues for a possible duplicate before creating a new issue: https://github.com/GeekyAnts/NativeBase/issues
- [X] Use the latest NativeBase release: https://github.com/GeekyAnts/NativeBase/releases
- [X] Check examples from NativeBase KitchenSink https://github.com/GeekyAnts/NativeBase-KitchenSink
- [X ] For discussion purpose make use of NativeBase Slack: http://slack.nativebase.io/
- [X] For queries related to theme, check Theme Variables from Docs and live NativeBase Theme Editor http://nativebase.io/customizer/
Issue Description
node, npm, react-native, react and native-base version, expo version if used, xcode version
node : v10.13.0 npm : v6.4.1 react : 16.8.3 react-native : 0.59.8 native-base : 2.12.1
Expected behaviour
Card should render with a simple text.
Actual behaviour
The below mentioned error occurs.
Emulator :

Console Log :

Error : Invariant Violation: [69,"RCTView",51,{"flexDirection":"row","alignItems":"center","paddingLeft":"<<NaN>>","paddingRight":"<<NaN>>","backgroundColor":-1}] is not usable as a native method argument
Steps to reproduce
import React, { Component } from 'react';
import {
Text,
Card,
CardItem
} from "native-base";
export default class Demo extends Component {
render() {
return (
<Card>
<CardItem>
<Text>Hello</Text>
</CardItem>
</Card>
)
}
}
Is the bug present in both iOS and Android or in any one of them?
Currently, i have only tested it in android platform
Any other additional info which would help us debug the issue quicker.
This bug is similar to this one --> #2647 As it is happening on a different component, i've created a new issue for this.
I have even tried passing the styling parameters paddingLeft,paddingRight in the component which are causing this error here but still it didn't work.
I am facing this too!
Edit:
Just to get the dev done, I got around it by removing "
I am having the same issue since updating to RN 60. Any updates?
I have checked it, it is working fine. Please try with the latest version of NativeBase.
It's working fine with the latest update of the library. But if you want to do it in the 2.12.1 , you can follow the steps below.
To avoid the crash in 2.12.1. Under native-base-theme folder, I added cardItemPaddingSide in Platform.js under variables & used it to add padding(Top,Left,Right,Bottom) for CardItem.js under Components folder.
** Attaching snippets of code change inside native-base-theme folder.
platform.js
// Card
cardDefaultBg: "#fff",
cardBorderColor: "#ccc",
cardBorderRadius: 2,
cardItemPadding: platform === "ios" ? 10 : 12,
// NativeBase Library Change (To avoid component crash for carditems)
cardItemPaddingSide: platform === "ios" ? 4 : 2
CardItem.js
export default (variables /*: * */ = variable) => {
const platform = variables.platform;
...
const cardItemTheme = {
...
...
".header": {
"NativeBase.Text": {
fontSize: 16,
fontWeight: platform === "ios" ? "600" : "500"
},
".bordered": {
"NativeBase.Text": {
color: variables.brandPrimary,
fontWeight: platform === "ios" ? "600" : "500"
},
borderBottomWidth: variables.borderWidth
},
borderBottomWidth: null,
paddingVertical: variables.cardItemPadding + 5,
// NativeBase Library Change (to avoid padding crash on carditem component)
paddingTop: variables.cardItemPaddingSide,
paddingBottom: variables.cardItemPaddingSide
},
...
...
flexDirection: "row",
alignItems: "center",
borderRadius: variables.cardBorderRadius,
padding: variables.cardItemPadding + 5,
paddingVertical: variables.cardItemPadding,
backgroundColor: variables.cardDefaultBg,
// NativeBase Library Change (to avoid padding crash on carditem component)
paddingLeft: variables.cardItemPaddingSide,
paddingRight : variables.cardItemPaddingSide,
paddingTop : variables.cardItemPaddingSide,
paddingBottom : variables.cardItemPaddingSide
},
...
}