0

Two views:

<View style={styles.rectangle}/>
<View style={styles.rectangle}/>    

I have these two rectangles that have a rectangle styling. I want to set custom flex for each of them, say the first one flex:2, second flex:5. How to achieve this without writing styles rectangle_flex_2 and rectangle_flex_5?

rectangle: {
    borderRadius: (5),
    backgroundColor: '#FFFFFF00',
    borderColor: 'red',
    borderWidth: 1,
 },
iamalminko
  • 105
  • 8

1 Answers1

1

You can do the following:

<View style={[styles.rectangle, { flex: 2 } ]}/>
<View style={[styles.rectangle, { flex: 5 } ]}/>

Here you are passing an array of style objects, the second object automatically overrides duplicate styles of the first one.

Tim
  • 10,459
  • 4
  • 36
  • 47