TypeScript for React & React Native
Props/state types, generics, discriminated unions, typing hooks, React Navigation types, API responses
1What is the main advantage of using TypeScript in a React Native project?
What is the main advantage of using TypeScript in a React Native project?
Jawaban
TypeScript detects type errors at compile time, before the application even runs. This significantly reduces production bugs related to incorrect types, improves IDE autocompletion and makes code more self-documenting. In a React Native project, this particularly helps with correctly typing props, state and API responses.
2What is the difference between type and interface in TypeScript?
What is the difference between type and interface in TypeScript?
Jawaban
Interfaces can be extended and merged through declaration merging, which is useful for extending third-party library types. Types are more flexible and can represent unions, intersections and primitive types. In practice, for simple objects both are interchangeable, but interfaces are preferred for React component props as they allow extension.
3How to correctly type the props of a React Native functional component?
How to correctly type the props of a React Native functional component?
Jawaban
The recommended method is to define an interface for props and use it as a generic type or parameter annotation. You can either use React.FC with the generic, or directly type the props in the function signature. The second approach is often preferred because React.FC implicitly includes children, which may not be desired.
How to type the useState hook with a custom type in TypeScript?
What is a generic type in TypeScript and what is it used for?
+19 pertanyaan wawancara
Topik wawancara React Native lainnya
JavaScript Essentials
React Fundamentals
React Native Basics
React Hooks
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
Platform-Specific Code
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
Kuasai React Native untuk wawancara berikutnya
Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.
Mulai gratis