Fundamentals & Core Concepts Interview Questions
Comprehensive fundamentals & core concepts interview questions and answers for React Native. Prepare for your next job interview with expert guidance.
Questions Overview
1. What is React Native and how does it differ from React?
Basic2. What are the core components in React Native?
Basic3. What is the purpose of the AppRegistry?
Basic4. What is the difference between Expo and React Native CLI?
Basic5. What is the Metro bundler and its role?
Basic6. How does React Native handle debugging?
Basic7. What is the purpose of package.json in React Native?
Basic8. What are the main threads in a React Native application?
Basic9. What is the role of babel.config.js in React Native?
Basic10. What is Hot Reloading and how does it differ from Live Reloading?
Basic11. What is the React Native bridge and how does it work?
Moderate12. How does React Native handle platform-specific code?
Moderate13. What are native modules and when should you use them?
Moderate14. What is the role of the Shadow Thread in React Native?
Moderate15. How does React Native handle JavaScript engines across platforms?
Moderate16. What is the purpose of linking in React Native?
Moderate17. How does React Native handle app permissions?
Moderate18. What is the role of the Metro configuration file?
Moderate19. How does React Native handle assets and resources?
Moderate20. What is the New Architecture in React Native?
Advanced21. How does the Fabric rendering system work?
Advanced22. What are TurboModules and how do they improve performance?
Advanced23. How does React Native handle memory management?
Advanced24. What is the role of JSI (JavaScript Interface) in React Native?
Advanced25. How does React Native handle native crash reporting?
Advanced26. What are the considerations for implementing security in React Native?
Advanced27. How does React Native handle app initialization and loading?
Advanced1. What is React Native and how does it differ from React?
BasicReact Native is a framework developed by Facebook that allows developers to build native mobile applications using JavaScript and React. Unlike React which creates a virtual DOM for browser rendering, React Native creates actual native UI components that are rendered on mobile devices. This means React Native apps have native performance while still allowing cross-platform development using a single codebase.
2. What are the core components in React Native?
BasicReact Native provides several core components that map directly to native UI elements: View (container), Text (text display), Image (image display), ScrollView (scrollable container), TextInput (text input field), TouchableOpacity/TouchableHighlight (touchable elements), and FlatList/SectionList (optimized scrollable lists).
3. What is the purpose of the AppRegistry?
BasicAppRegistry is the entry point to run a React Native application. It provides the registerComponent method used to register the root component of the application. This registration tells React Native which component to render when the application starts, similar to ReactDOM.render in web applications.
4. What is the difference between Expo and React Native CLI?
BasicExpo provides a managed workflow with pre-built components and services, making it easier to start but with limited native module access. React Native CLI offers a bare workflow with full native code access but requires more setup and native development knowledge.
5. What is the Metro bundler and its role?
BasicMetro is React Native's JavaScript bundler that combines all JavaScript code and dependencies into a single file. It handles transpilation, asset management, and provides hot reloading during development. It's optimized specifically for React Native's mobile environment needs.
6. How does React Native handle debugging?
BasicReact Native offers multiple debugging options: Chrome Developer Tools for JavaScript debugging, React Developer Tools for component inspection, built-in Debug menu on devices, and console logging. It also supports remote debugging and various third-party debugging tools.
7. What is the purpose of package.json in React Native?
Basicpackage.json manages project dependencies, scripts, and configuration. It lists all npm packages required by the project, defines scripts for development and building, and contains metadata about the project including name, version, and license information.
8. What are the main threads in a React Native application?
BasicReact Native runs on three main threads: 1) Main Thread (Native UI), 2) JavaScript Thread (JS execution), and 3) Shadow Thread (layout calculations). These threads work together through the bridge to create the native application experience.
9. What is the role of babel.config.js in React Native?
Basicbabel.config.js configures Babel transpilation settings for the project. It defines how modern JavaScript features are converted to compatible code, handles JSX transformation, and can include various plugins and presets for additional functionality.
10. What is Hot Reloading and how does it differ from Live Reloading?
BasicHot Reloading updates only the changed components while maintaining the app's state. Live Reloading refreshes the entire app and resets state when code changes. Hot Reloading is more efficient during development as it preserves the development flow.
11. What is the React Native bridge and how does it work?
ModerateThe bridge is the communication layer between JavaScript and native code. It serializes data and handles asynchronous communication between JS and native threads. All native module calls and UI updates pass through the bridge, which can impact performance with heavy data transfers.
12. How does React Native handle platform-specific code?
ModerateReact Native provides Platform.select(), platform-specific file extensions (.ios.js/.android.js), Platform.OS checks, and platform-specific components. These methods allow writing platform-specific logic while maintaining a shared codebase.
13. What are native modules and when should you use them?
ModerateNative modules expose platform-specific APIs to JavaScript through the bridge. They're used when requiring direct access to platform APIs, implementing performance-critical features, or integrating third-party SDKs that don't have React Native implementations.
14. What is the role of the Shadow Thread in React Native?
ModerateThe Shadow Thread handles layout calculations using Yoga (Facebook's cross-platform layout engine). It processes flex layouts and converts them to native layouts, running separately from the main thread to ensure smooth UI performance.
15. How does React Native handle JavaScript engines across platforms?
ModerateiOS uses JavaScriptCore (JSC) by default, while Android can use either JSC or Hermes. Hermes is Facebook's custom JS engine optimized for React Native, offering better performance, reduced memory usage, and faster startup times.
16. What is the purpose of linking in React Native?
ModerateLinking handles deep linking and URL scheme integration in React Native apps. It provides methods to open external links and handle incoming deep links, enabling integration with other apps and web content.
17. How does React Native handle app permissions?
ModerateReact Native provides APIs to request and check platform permissions (camera, location, etc.). These are handled through native modules and require configuration in platform-specific files (AndroidManifest.xml, Info.plist).
18. What is the role of the Metro configuration file?
Moderatemetro.config.js customizes the Metro bundler's behavior, including module resolution, asset handling, and transformation settings. It can be modified to support different file types, customize bundling, and optimize build performance.
19. How does React Native handle assets and resources?
ModerateAssets are handled through the Metro bundler, which can process images, fonts, and other resources. Platform-specific asset selection is supported through asset suffixes, and the require syntax is used for static asset references.
20. What is the New Architecture in React Native?
AdvancedThe New Architecture introduces Fabric (new rendering system) and TurboModules (improved native modules). It reduces bridge overhead, improves performance, and enables better native integration through codegen and static typing.
21. How does the Fabric rendering system work?
AdvancedFabric is a C++ rendering system that enables synchronous operations between JS and native code. It introduces a new threading model, improves layout performance, and enables concurrent rendering features.
22. What are TurboModules and how do they improve performance?
AdvancedTurboModules provide direct JS to native communication without serialization overhead. They use codegen to create type-safe interfaces, lazy load modules, and enable better memory management compared to traditional native modules.
23. How does React Native handle memory management?
AdvancedReact Native manages memory through automatic garbage collection in JS and ARC/GC in native code. Understanding the bridge's role in memory usage, implementing proper cleanup in components, and monitoring memory leaks are crucial.
24. What is the role of JSI (JavaScript Interface) in React Native?
AdvancedJSI enables direct communication between JavaScript and native code without going through the bridge. It provides a way to hold native references in JavaScript and enables synchronous native method calls.
25. How does React Native handle native crash reporting?
AdvancedNative crashes are handled through platform-specific crash reporting tools and services. Integration requires native module setup, symbolication for JavaScript stack traces, and proper error boundary implementation.
26. What are the considerations for implementing security in React Native?
AdvancedSecurity involves handling data encryption, secure storage, certificate pinning, code obfuscation, and protecting against common mobile vulnerabilities. Platform-specific security features must be properly implemented.
27. How does React Native handle app initialization and loading?
AdvancedApp initialization involves native bootstrap, JS engine initialization, bundle loading, and component mounting. Understanding this process is crucial for optimizing startup time and implementing splash screens.