Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

child views are overriding parent view's boundary. [react-native]

I am trying to do as following in react-native. I am setting a borderRadius in the parent view. But the child is overriding that. So in the final view, the borderRadius is not visible

export default class FlexDimensionsBasics extends Component {
  render() {
    return (
      // Try removing the `flex: 1` on the parent View.
      // The parent will not have dimensions, so the children can't expand.
      // What if you add `height: 300` instead of `flex: 1`?
      <View style={{flex: 1, borderRadius:30, backgroundColor:'red'}}>
        <View style={{flexGrow: 10, backgroundColor: 'powderblue'}} />
        <View style={{flexGrow: 20, backgroundColor: 'skyblue'}} />
        <View style={{flexGrow: 30, backgroundColor: 'steelblue'}} />
      </View>
    );
  }
}

enter image description here

is there anything which I am missing to add?

like image 219
Vikash Avatar asked Aug 29 '18 16:08

Vikash


People also ask

Can we pass data from child to parent in react native?

To pass data from child to parent component in React:Pass a function as a prop to the Child component. Call the function in the Child component and pass the data as arguments. Access the data in the function in the Parent .

How do you use overflow in react native?

According to the article, you can use react-native-view'overflow library (a bridging header written to support the overflow in react-native android. All you need to do is wrap the overflowcomponent in the <ViewOverflow> . Hope this helps!

Can you use JavaScript libraries in React?

The react-script-tag is a package that comes up with a <script> tag that supports universal rendering. With the help of this library, we can directly append the <script> tag to our document. And inside the 'src' attribute of the script tag, we can include the URL of the external JavaScript library.


1 Answers

Add overflow: "hidden" to your parent style

like image 195
Antoine Grandchamp Avatar answered Oct 03 '22 19:10

Antoine Grandchamp