React Native Cheatsheet
Introduction
React Native is a framework for building native apps using React. This cheatsheet covers key concepts, components,
and APIs.
React Native Cheatsheet
Core Concepts
1. JSX: Write UI components with XML-like syntax.
2. Components: Use functional or class components.
3. Props: Pass data to components.
4. State: Manage local component state.
5. Lifecycle Methods: Use hooks like useEffect or class methods (e.g., componentDidMount).
React Native Cheatsheet
Core Components
1. View: A container for other components.
2. Text: Displays text.
3. TextInput: Accepts user input.
4. ScrollView: Provides scrolling capability.
5. FlatList: Optimized scrolling list.
6. Button: Triggers user actions.
React Native Cheatsheet
Styling
1. Flexbox: Used for layout and alignment.
2. Stylesheets: Use StyleSheet.create to define styles.
3. Inline Styles: Pass style objects directly.
4. Global Styles: Use context or libraries like styled-components.
React Native Cheatsheet
Navigation
1. react-navigation: Most popular navigation library.
2. Types: Stack, Tab, Drawer navigation.
3. Installation: npm install @react-navigation/native
4. Example:
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
React Native Cheatsheet
APIs and Libraries
1. Networking: fetch, axios for HTTP requests.
2. State Management: Redux, MobX, Context API.
3. Animations: Animated, Reanimated.
4. Storage: AsyncStorage, SecureStore.
5. Permissions: react-native-permissions.
React Native Cheatsheet
Debugging and Testing
1. Debugging: Use console.log, Flipper, or React DevTools.
2. Testing: Jest, Enzyme, React Native Testing Library.
3. Error Handling: Use try-catch blocks and ErrorBoundary.
React Native Cheatsheet
Deployment
1. Android: Generate APK or AAB using Gradle.
2. iOS: Archive and distribute via Xcode.
3. Over-the-air Updates: Use CodePush.