2

I need a particular style to apply only for android and needs to have no effect when on iOS.

My code snippet is somewhat like this:

<CardItem
  style={{
borderWidth: 0,
borderLeftWidth: 0,
borderRightWidth: 0,
borderTopLeftRadius: 10,
borderTopRightRadius: 10,
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
backgroundColor: "#fff",
overflow: Platform.OS == "ios" ? "hidden":"auto"
}}
cardBody
>

I need the overflow to be hidden only on iOS and needs no effect when on android. I have used overflow: Platform.OS == "ios" ? "hidden":"auto", but this doesn't look apt for the scenario.

7
  • so you want to remove overflow property for android? Commented Apr 18, 2019 at 9:54
  • Would this work for you overflow: Platform.OS == "ios" && "hidden" Commented Apr 18, 2019 at 10:02
  • 2
    I guess it might be because after backgroundColor is no comma, try to put there comma and see if it works Commented Apr 18, 2019 at 10:11
  • @Zirek good catch :) Commented Apr 18, 2019 at 10:17
  • 2
    @Zirek it was just a copy/paste error..fixed it now..hehe Commented Apr 18, 2019 at 10:30

1 Answer 1

4

The overflow property doesn't have an 'auto' value in React Native. It's an enum with these options:

enum('visible', 'hidden', 'scroll')

You can set 'visible' (the default value) instead of 'auto' for Android. This should work:

overflow: Platform.OS == "ios" ? "hidden": "visible"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.