React Hooks
useState, useEffect, useContext, useRef, useCallback, useMemo, custom hooks
1Which function allows declaring a state variable in a React functional component?
Which function allows declaring a state variable in a React functional component?
Answer
useState is the fundamental hook for managing local state in functional components. It returns an array containing the current state value and a function to update it. Unlike class components that use this.state, functional components use useState for each independent state variable.
2What is the correct syntax to use useState with an initial value of 0?
What is the correct syntax to use useState with an initial value of 0?
Answer
The useState syntax uses array destructuring. The first element is the current state value, the second is the setter function to update it. The naming convention is to prefix the setter with 'set' followed by the capitalized variable name, like setCount for the count variable.
3When does the useEffect callback without a dependency array execute?
When does the useEffect callback without a dependency array execute?
Answer
Without a dependency array, useEffect runs after every render of the component, including the first render and all subsequent re-renders. This can cause performance issues as the code runs on every update. To limit executions, provide a dependency array specifying which values to watch.
How to run a useEffect only on component mount?
What is the purpose of the function returned by a useEffect?
+17 interview questions
Other React Native interview topics
JavaScript Essentials
React Fundamentals
React Native Basics
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
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
Master React Native for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free