# Top 30 Câu Hỏi Phỏng Vấn React Native: Hướng Dẫn Đầy Đủ 2026 > 30 câu hỏi phỏng vấn React Native được hỏi nhiều nhất. Câu trả lời chi tiết kèm ví dụ mã để giành được vị trí lập trình viên di động. - Published: 2026-02-01 - Updated: 2026-04-27 - Author: SharpSkill - Tags: react native interview, mobile interview, react native questions, javascript, technical interview - Reading time: 20 min --- Phỏng vấn kỹ thuật React Native đánh giá kỹ năng phát triển ứng dụng di động đa nền tảng, các đặc thù của iOS/Android cùng các mẫu thiết kế về hiệu năng. Hướng dẫn này tổng hợp 30 câu hỏi xuất hiện thường xuyên nhất, kèm theo câu trả lời chi tiết và ví dụ mã giúp việc chuẩn bị diễn ra hiệu quả. > **Lời khuyên chuẩn bị** > > Các câu hỏi trải dài từ kiến thức nền tảng đến những khái niệm nâng cao. Nắm vững kiến trúc React Native và hiểu rõ những khác biệt so với React web là yếu tố then chốt để vượt qua buổi phỏng vấn. ## Kiến Thức Cơ Bản React Native ### 1. Sự khác biệt giữa React và React Native là gì? React là một thư viện dùng để xây dựng giao diện web, trong khi React Native cho phép phát triển ứng dụng di động native trên iOS và Android. Khác biệt cốt lõi nằm ở cơ chế render: React sử dụng Virtual DOM để chuyển đổi sang các phần tử HTML, còn React Native sử dụng cầu nối (bridge) giao tiếp với các thành phần native trên từng nền tảng. ```jsx // React (Web) - uses HTML elements function WebComponent() { return (
Web text
) } // React Native - uses native components import { View, Text, TouchableOpacity, StyleSheet } from 'react-native' function NativeComponent() { return ( Native text Press ) } const styles = StyleSheet.create({ container: { flex: 1, padding: 16 } }) ``` Các thành phần React Native được dịch thành UIView trên iOS và android.view trên Android, mang lại hiệu năng tương đương ứng dụng native. ### 2. Kiến trúc của React Native hoạt động như thế nào? React Native sử dụng kiến trúc ba lớp: JavaScript, Bridge (hoặc JSI trong kiến trúc mới) và Native. Mã JavaScript chạy trên một động cơ JS (Hermes hoặc JavaScriptCore). Việc giao tiếp với mã native diễn ra thông qua tuần tự hóa JSON ở kiến trúc cũ, hoặc thông qua JSI (JavaScript Interface) ở kiến trúc mới. ```jsx // Old architecture: asynchronous communication via Bridge // The Bridge serializes messages as JSON between JS and Native // New architecture (Fabric + TurboModules) // JSI enables synchronous direct calls to native modules // Example TurboModule usage import { TurboModuleRegistry } from 'react-native' // Synchronous access to native module const DeviceInfo = TurboModuleRegistry.get('DeviceInfo') const deviceName = DeviceInfo.getDeviceName() // Synchronous call // With Fabric, rendering is smoother // Components can be created synchronously // Reducing jank during animations ``` Kiến trúc mới cải thiện đáng kể hiệu năng nhờ loại bỏ tuần tự hóa JSON và cho phép gọi đồng bộ. ### 3. Metro bundler là gì? Metro là bundler JavaScript được React Native sử dụng. Bundler này chuyển đổi mã nguồn thành một gói được tối ưu cho việc thực thi trên thiết bị di động. Metro phụ trách việc giải quyết module, biến đổi mã (qua Babel) và hỗ trợ hot reloading trong quá trình phát triển. ```javascript // metro.config.js const { getDefaultConfig } = require('expo/metro-config') const config = getDefaultConfig(__dirname) // Custom configuration config.resolver.assetExts.push('db') // Add extensions config.resolver.sourceExts.push('cjs') // CommonJS support // Transformer configuration config.transformer.babelTransformerPath = require.resolve( 'react-native-svg-transformer' ) // Production optimizations config.transformer.minifierConfig = { keep_classnames: true, keep_fnames: true, mangle: { keep_classnames: true, keep_fnames: true } } module.exports = config ``` Metro hỗ trợ Fast Refresh, cho phép áp dụng thay đổi tức thời mà không làm mất trạng thái của ứng dụng. ### 4. Hãy giải thích StyleSheet.create và các lợi ích của nó `StyleSheet.create` tối ưu hóa các style bằng cách kiểm tra và chuyển chúng thành tham chiếu số, qua đó giảm chi phí trên bridge. ```jsx // ❌ Inline styles - recreated on every render function BadExample() { return ( Title ) } // ✅ StyleSheet.create - optimized and validated const styles = StyleSheet.create({ container: { flex: 1, padding: 16, backgroundColor: '#fff' }, title: { fontSize: 18, fontWeight: 'bold' }, // Style composition row: { flexDirection: 'row', alignItems: 'center', gap: 8 } }) function GoodExample() { return ( Title {/* Style combination */} Content ) } // StyleSheet.absoluteFillObject for absolute positioning const overlayStyles = StyleSheet.create({ overlay: { ...StyleSheet.absoluteFillObject, backgroundColor: 'rgba(0,0,0,0.5)' } }) ``` ### 5. Khác biệt giữa Flexbox web và React Native là gì? React Native dùng Flexbox nhưng với những giá trị mặc định khác so với phiên bản web, được điều chỉnh để phù hợp với giao diện di động theo chiều dọc. ```jsx // Key differences from web const styles = StyleSheet.create({ container: { // flexDirection: 'column' by default (vs 'row' on web) // alignItems: 'stretch' by default flex: 1 }, // React Native Flexbox row: { flexDirection: 'row', // Horizontal justifyContent: 'space-between', // Main axis alignItems: 'center', // Cross axis flexWrap: 'wrap', // Line wrapping gap: 8 // Supported since RN 0.71 }, // Flex grow/shrink flexItem: { flex: 1, // Equivalent to flex: 1 1 0 flexGrow: 1, // Grow to fill flexShrink: 0, // Don't shrink flexBasis: 100 // Base size }, // Absolute positioning absolute: { position: 'absolute', top: 0, left: 0, right: 0, bottom: 0 } }) // Practical example: card with image and content function Card() { return ( Title Description ) } const cardStyles = StyleSheet.create({ container: { flexDirection: 'row', backgroundColor: '#fff', borderRadius: 8, overflow: 'hidden' }, image: { width: 100, height: 100 }, content: { flex: 1, // Takes remaining space padding: 12, justifyContent: 'center' }, title: { fontSize: 16, fontWeight: '600' }, description: { fontSize: 14, color: '#666' } }) ``` ## Điều Hướng và Thành Phần ### 6. Làm thế nào để triển khai điều hướng với React Navigation? React Navigation là giải pháp tiêu chuẩn cho việc điều hướng trong React Native. Thư viện này cung cấp nhiều loại navigator phù hợp với các mẫu thiết kế di động. ```jsx // Installing dependencies // npm install @react-navigation/native @react-navigation/native-stack // npm install react-native-screens react-native-safe-area-context import { NavigationContainer } from '@react-navigation/native' import { createNativeStackNavigator } from '@react-navigation/native-stack' import { createBottomTabNavigator } from '@react-navigation/bottom-tabs' // TypeScript typing for navigation params type RootStackParamList = { Home: undefined Profile: { userId: string } Settings: { section?: string } } const Stack = createNativeStackNavigator() const Tab = createBottomTabNavigator() // Tab navigation function TabNavigator() { return ( ({ tabBarIcon: ({ focused, color, size }) => { // Dynamic icon based on tab const iconName = route.name === 'Home' ? 'home' : 'settings' return }, tabBarActiveTintColor: '#007AFF', tabBarInactiveTintColor: 'gray' })} > ) } // Stack navigation function App() { return ( ({ title: `Profile ${route.params.userId}` })} /> ) } ``` ### 7. Làm thế nào để xử lý danh sách hiệu năng cao với FlatList? `FlatList` được tối ưu cho danh sách dài nhờ cơ chế ảo hóa tự động, chỉ render các phần tử đang hiển thị trên màn hình. ```jsx import { FlatList, RefreshControl } from 'react-native' function ProductList() { const [products, setProducts] = useState([]) const [refreshing, setRefreshing] = useState(false) const [loading, setLoading] = useState(false) // Initial loading const fetchProducts = async (page = 1) => { const response = await api.getProducts(page) return response.data } // Pull-to-refresh const onRefresh = useCallback(async () => { setRefreshing(true) const data = await fetchProducts(1) setProducts(data) setRefreshing(false) }, []) // Infinite pagination const loadMore = useCallback(async () => { if (loading) return setLoading(true) const nextPage = Math.ceil(products.length / 20) + 1 const data = await fetchProducts(nextPage) setProducts(prev => [...prev, ...data]) setLoading(false) }, [products.length, loading]) // Item rendering const renderItem = useCallback(({ item }) => ( ), []) // Key extraction const keyExtractor = useCallback((item) => item.id.toString(), []) // Item separator const ItemSeparator = useCallback(() => ( ), []) return ( } // Infinite pagination onEndReached={loadMore} onEndReachedThreshold={0.5} ListFooterComponent={loading ? : null} // Empty list ListEmptyComponent={} /> ) } ``` > **Tối ưu FlatList** > > Luôn ghi nhớ `renderItem` bằng `useCallback` và tách các thành phần nặng ra khỏi nó. Tránh dùng hàm inline trong `renderItem` vì có thể gây ra những lượt render lại không cần thiết. ### 8. Khác biệt giữa TouchableOpacity, Pressable và TouchableHighlight là gì? Các thành phần này xử lý tương tác chạm với phản hồi trực quan khác nhau. ```jsx import { TouchableOpacity, TouchableHighlight, Pressable, StyleSheet } from 'react-native' function InteractionExamples() { return ( {/* TouchableOpacity: reduces opacity on touch */} console.log('Pressed')} style={styles.button} > TouchableOpacity {/* TouchableHighlight: adds background color */} console.log('Pressed')} style={styles.button} > TouchableHighlight {/* Pressable: modern API with more control */} console.log('Pressed')} onLongPress={() => console.log('Long press')} delayLongPress={500} style={({ pressed }) => [ styles.button, pressed && styles.buttonPressed ]} > {({ pressed }) => ( {pressed ? 'Pressed!' : 'Pressable'} )} {/* Pressable with hitSlop to enlarge touch area */} console.log('Pressed')} style={styles.smallButton} > Small button ) } const styles = StyleSheet.create({ container: { gap: 16, padding: 20 }, button: { backgroundColor: '#007AFF', padding: 16, borderRadius: 8, alignItems: 'center' }, buttonPressed: { backgroundColor: '#0056b3', transform: [{ scale: 0.98 }] }, textPressed: { color: '#fff' }, smallButton: { padding: 8, backgroundColor: '#eee' } }) ``` `Pressable` được khuyến nghị cho các dự án mới nhờ khả năng kiểm soát rộng hơn và API nhất quán hơn. ### 9. Làm thế nào để tạo các hiệu ứng động mượt mà? React Native cung cấp nhiều API hoạt hình: Animated (tích hợp sẵn) và Reanimated (hiệu năng cao hơn). ```jsx import { Animated, Easing } from 'react-native' import Reanimated, { useSharedValue, useAnimatedStyle, withSpring, withTiming } from 'react-native-reanimated' // Animation with Animated (native API) function FadeInView({ children }) { const fadeAnim = useRef(new Animated.Value(0)).current useEffect(() => { Animated.timing(fadeAnim, { toValue: 1, duration: 500, easing: Easing.ease, useNativeDriver: true // Performant on UI thread }).start() }, []) return ( {children} ) } // Animation with Reanimated (recommended for complex animations) function BouncyButton() { const scale = useSharedValue(1) const animatedStyle = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }] })) const handlePressIn = () => { scale.value = withSpring(0.95, { damping: 10, stiffness: 400 }) } const handlePressOut = () => { scale.value = withSpring(1, { damping: 10, stiffness: 400 }) } return ( Press ) } // List animation with LayoutAnimation import { LayoutAnimation, UIManager, Platform } from 'react-native' // Enable on Android if (Platform.OS === 'android') { UIManager.setLayoutAnimationEnabledExperimental?.(true) } function AnimatedList() { const [items, setItems] = useState([]) const addItem = () => { // Configure animation before state change LayoutAnimation.configureNext(LayoutAnimation.Presets.spring) setItems(prev => [...prev, { id: Date.now() }]) } const removeItem = (id) => { LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) setItems(prev => prev.filter(item => item.id !== id)) } return (