One thing you might have noted in our StyleSheet
is a property called flex
. This pertains to Flexbox, a CSS layout system that provides consistency in your layout across different screen sizes. Flexbox in React Native works similar to its CSS specification, with only a couple of differences. The most important differences to be noted are that the default flex
direction has been flipped to column
on React Native, as opposed to row
on the Web, aligning items, by default, to the stretch
property for React Native instead of flex-start
in the browser, and the flex
parameter only supports a single number as its value in React Native.
We will pick up a lot on Flexbox as we go through these projects; we'll start by taking a look at just the basics.
The flex
property of your layout works a bit differently from how it operates in CSS. In React Native, it accepts a single digit number. If its number is a positive number (meaning greater than 0), the component that has this property will become flexible.