React Native with TypeScript Interview Questions (2 Years Experience)
1. What is the difference between React Native and React?
- React is for web; React Native is for mobile.
- React uses DOM; React Native uses native components.
- React uses CSS; React Native uses StyleSheet.
2. How do you define props and state with TypeScript in a functional component?
type Props = {
name: string;
age?: number;
};
const MyComponent: React.FC<Props> = ({ name, age }) => {
const [count, setCount] = useState<number>(0);
return <Text>{name} is {age} years old. Count: {count}</Text>;
};
3. How is TypeScript helpful in React Native?
- Type safety
- Auto-completion
- Better refactoring and readability
- IDE support
4. How do you handle navigation with TypeScript in React Native?
type RootStackParamList = {
Home: undefined;
Details: { itemId: number };
};
const Stack = createStackNavigator<RootStackParamList>();
5. What are some performance optimization techniques in React Native?
React Native with TypeScript Interview Questions (2 Years Experience)
- Use React.memo, useMemo, useCallback
- Use FlatList over ScrollView
- Avoid anonymous functions in props
- Use react-native-fast-image
6. What is the difference between View, SafeAreaView, and ScrollView?
- View: basic layout container
- SafeAreaView: avoids notches/status bar overlap
- ScrollView: scrollable layout (use FlatList for performance)
7. How do you type a FlatList with TypeScript?
type Item = { id: string; name: string; };
<FlatList<Item>
data={data}
keyExtractor={(item) => item.id}
renderItem={({ item }) => <Text>{item.name}</Text>} />
8. How do you structure a React Native project with TypeScript?
/components, /screens, /navigation, /types, /services, /utils
9. How do you fetch data in React Native?
useEffect(() => {
axios.get('https://api.example.com/data')
.then(res => setData(res.data))
.catch(err => console.error(err));
}, []);
10. What are some common third-party libraries you use?
- Navigation: @react-navigation
- Forms: formik/react-hook-form
React Native with TypeScript Interview Questions (2 Years Experience)
- Validation: yup
- State: redux/zustand
- Storage: async-storage
11. How do you debug React Native apps?
- Use React Native Debugger, Flipper, console.log, Redux DevTools
12. What is the use of useRef in React Native?
- Persist values across renders
- Access TextInput refs or timers
13. How do you apply conditional styling in React Native?
<View style={[styles.box, isActive && styles.activeBox]} />
14. How do you type navigation params in TypeScript?
type RootStackParamList = {
Home: undefined;
Details: { id: number };
};
const DetailsScreen: React.FC<Props> = ({ route }) => {
const { id } = route.params;
};
15. What is the difference between any, unknown, and never in TypeScript?
- any: disables type checking
- unknown: safe version of any
- never: function never returns