Platform-Specific Code
Platform.OS, Platform.select, .ios.js/.android.js, native APIs access
1Which property should be used to determine if the application is running on iOS or Android?
Which property should be used to determine if the application is running on iOS or Android?
Respuesta
Platform.OS returns a string indicating the current operating system: 'ios' for iOS and 'android' for Android. This property is the most direct method to check the running platform and adapt the application behavior accordingly.
2What is the correct syntax to use Platform.select to apply different styles based on the platform?
What is the correct syntax to use Platform.select to apply different styles based on the platform?
Respuesta
Platform.select accepts an object with 'ios', 'android' and optionally 'default' keys. This method allows defining platform-specific values in a declarative and concise way, which is particularly useful for styles and configurations.
3How to create a component with different implementations for iOS and Android using file extensions?
How to create a component with different implementations for iOS and Android using file extensions?
Respuesta
React Native automatically detects files with .ios.js and .android.js extensions during bundling. By creating two files like Button.ios.js and Button.android.js, importing 'Button' will automatically load the appropriate version based on the platform, without explicit conditions in the code.
Which Platform property allows checking the operating system version?
What is the main advantage of using file extensions (.ios.js/.android.js) compared to Platform.select?
+15 preguntas de entrevista
Otros temas de entrevista React Native
JavaScript Essentials
React Fundamentals
React Native Basics
React Hooks
TypeScript for React & React Native
React Native Components & API
React Native Styling & Layout
React Native Navigation
React Native State Management
React Native Networking & API
Data Persistence
Forms & Validation
React Native Animations
Native Modules & Bridge
Permissions & Device APIs
Push Notifications
React Native Testing
React Native Debugging
Build & Deployment
Expo vs React Native Bare
Performance Optimization
Memory Management
Architecture Patterns
React Native New Architecture
Security Best Practices
Offline-First Architecture
React Native CI/CD
Monorepo & Code Sharing
Advanced Topics
App Lifecycle & Background Execution
Authentication & Session Management
Monitoring & Crash Reporting
Domina React Native para tu próxima entrevista
Accede a todas las preguntas, flashcards, tests técnicos, ejercicios de code review y simuladores de entrevista.
Empieza gratis