React Native interview question · Most asked
How does layout work in React Native compared with CSS on the web?
Summary
React Native uses Flexbox for all layout, but flexDirection defaults to column, there's no cascade or class names, and dimensions are unitless density-independent pixels.
Longer Answer
Styles are JavaScript objects (StyleSheet.create), applied per component; text styles don't inherit except within nested Text. flex: 1 fills available space. There is no CSS grid; percentages, gap, aspectRatio and absolute positioning cover most needs. Safe areas (notches, home indicators) must be handled explicitly, and dark mode via useColorScheme().
Key Points
- Flexbox only, column by default.
- Style objects, no cascade.
- Handle safe areas and dark mode yourself.
Deep dive: Mobile Apps with React Native and Expo: Layout and Styling
More most-asked React Native questions
- What is React Native, and how does it differ from a hybrid (WebView) app?
- Explain the React Native threading model.
- What is the React Native New Architecture?
- When would you use FlatList instead of ScrollView, and how do you make long lists fast?
- Where should you store data on the device, and what should never go in AsyncStorage?
- How would you make a React Native app work offline?
- How do you handle authentication tokens in a mobile app?
- A screen in your React Native app is slow. How do you investigate and fix it?