React Native Flexbox flexDirection Property
In this article, We are going to see the Flexbox flexDirection Property in React Native. Flexbox has three main properties. One of them is flexDirection. The flexDirection property is used to determine the alignment of its elements in the horizontal or vertical directions. It established the main axis of the layout.
- column: It is the default value of flexDirection property. It aligns the children items from top to bottom directions.
- row: It aligns the children’s items from left to right directions.
- column-reverse: It aligns the children items from bottom to top directions. It is the reverse of the column value.
- row-reverse: It aligns the children from right to left directions.
- Step 1: Open your terminal and install expo-cli by the following command.
npm install -g expo-cli
- Step 2: Now create a project by the following command.
expo init myapp
- Step 3: Now go into your project folder i.e. myapp.
Project Structure: It will look like this.
Example: Here in this example, flexDirection is set to the column.
Start the server by using the following command.
npm run android
Output: If your emulator did not open automatically then you need to do it manually. First, go to your android studio and run the emulator. Now start the server again.
Now we will keep the entire code the same and just do the changes in flexDirection property value to see the change.
- Property row illustration, use the following syntax:
- Property column-reverse illustration, use the following syntax:
- Property row-reverse illustration, use the following syntax: