react-native-paper does not work on react-native 0.58.x

Created on 28 Jan 2019  路  14Comments  路  Source: callstack/react-native-paper


Current behaviour

ReactNativePaper is not working in lastet version of reactnative 0.58 and 0.58.1

Expected behaviour

whatsapp image 2019-01-28 at 6 10 53 pm

Code sample

/**
 * @format
 * @lint-ignore-every XPLATJSCOPYRIGHT1
 */
import React from "react";
import { AppRegistry } from "react-native";
import { name as appName } from "./app.json";
import {
  Provider,
  Button,
  DarkTheme,
  Surface,
  Text,
  Card
} from "react-native-paper";

const Main = () => (
  <Provider theme={DarkTheme}>
    <Card elevation={1}>
      <Card.Content>
        <Text>Hello o</Text>
      </Card.Content>
    </Card>
  </Provider>
);

AppRegistry.registerComponent(appName, () => Main);

Screenshots (if applicable)

What have you tried

Your Environment

| software | version
| --------------------- | -------
| ios or android | android
| react-native | 58.1
| react-native-paper | 2.6.3
| node | 8.11.3
| npm or yarn | 1.10.1

Package.json code

{
  "name": "barbendingEstimation",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.6.3",
    "react-native": "0.58.1",
    "react-native-paper": "^2.6.3",
    "react-native-vector-icons": "^6.2.0"
  },
  "devDependencies": {
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "24.0.0",
    "jest": "24.0.0",
    "metro-react-native-babel-preset": "0.51.1",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

bug

Most helpful comment

I can confirm this as adding style={{elevation: 1}} on button works like a bomb 馃檶馃徎

All 14 comments

We are aware of compatibility issue. We'll work on this at some point (but I am guessing when expo updates).

Ok. i downgrade my application to old react-native version.
but while debugging i found that flattenStyle function return object reference instead of number in surface component. so, in shadow function always it's going to default block instead of correct case blocks.

in that function we calculated

default:
      height = elevation - 1; // this result gives NaN result
      radius = elevation;

I didn't debugged further.

This should be fixed by ec872a5c6188d8fdded269ac2e98f4ba5881e679

Can you try the latest version and let me know if it works?

Yeah.
It's working.
Thanks for the quick fix.

While checking react-native version is 0.58.3.

@syedabuthahirm are you sure you were on 0.58.3? Or @satya164 the same fix might be needed for Button as it gets the same error. 0.58.3 & 2.7.0

Looking at the code above it does not use Button. Only card (surface).

Thanks for the good work guys.

@hugopretorius72 i think this issue was in shadow function not in button component. Surface is basic component. button and card component inherited from surface @hugopretorius72.

I can confirm this as adding style={{elevation: 1}} on button works like a bomb 馃檶馃徎

@syedabuthahirm thanks for that. Not sure why that fixes it but it does, hope it can help you troubleshoot

Still having this (smilar) problem with version 2.11.0 and react-native version 0.58.4

@koo27 can you open a new issue with code sample and error message?

@satya164 Sure! I'm still deep debugging in order to get as much information as I can. Thank you

@satya164 & @koo27 i checked with react-native-0.58.3.i will check again with react-native-0.58.4

@syedabuthahirm @satya164 my bad!
The issue wasn't related to react-native-paper anymore! The last version actually solves the problem.
The bug I face is related only to the new version of react-native (basically it throws me error when I have something like width, right, height, etc. calculated dynamically directly into the style).

hi everyone, this problem persists in react-native 0.59.5, or maybe returned idk. The solution pointed by @hugopretorius72 still working for Button but not worked for BottomNavigation.
I have migrated from 0.57.8 to 0.59.5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

makhataibar picture makhataibar  路  4Comments

ButuzGOL picture ButuzGOL  路  4Comments

mihaidaviddev picture mihaidaviddev  路  3Comments

talaikis picture talaikis  路  3Comments

satya164 picture satya164  路  4Comments