Learn the development workflow, best practices, and tools for building scalable React Native applications
Essential commands and development setup
npm start
Starts the Metro development server
npm run ios
Run on iOS simulator
npm run android
Run on Android emulator
React Native Fast Refresh is enabled by default. Changes are reflected instantly:
Maintain consistent code quality with automated tools
npm run lint
Check for code quality issues
npm run format
Auto-format code style
npm run type-check
// src/types/user.ts
export interface User {
id: string;
name: string;
email: string;
avatar?: string;
createdAt: Date;
}
export interface CreateUserRequest {
name: string;
email: string;
}
export interface AuthState {
user: User | null;
token: string | null;
isLoading: boolean;
}Unit tests, integration tests, and E2E testing setup
npm test
npm run test:watch
npm run test:coverage
// __tests__/components/Button.test.tsx
import React from 'react';
import { render, fireEvent } from '@testing-library/react-native';
import { Button } from '@/components/ui/Button';
describe('Button Component', () => {
it('renders correctly', () => {
const { getByText } = render(
<Button title="Press me" onPress={() => {}} />
);
expect(getByText('Press me')).toBeTruthy();
});
it('calls onPress when pressed', () => {
const mockOnPress = jest.fn();
const { getByText } = render(
<Button title="Press me" onPress={mockOnPress} />
);
fireEvent.press(getByText('Press me'));
expect(mockOnPress).toHaveBeenCalledTimes(1);
});
});// __tests__/services/api.test.ts
import { apiClient } from '@/services/api';
import { mockServer } from '../mocks/server';
describe('API Client', () => {
beforeAll(() => mockServer.listen());
afterEach(() => mockServer.resetHandlers());
afterAll(() => mockServer.close());
it('fetches user data successfully', async () => {
const user = await apiClient.getUser('123');
expect(user).toEqual({
id: '123',
name: 'John Doe',
email: 'john@example.com'
});
});
});Tools and techniques for debugging React Native apps
Standalone app with React DevTools, Redux DevTools, and network inspect
brew install react-native-debugger
Advanced debugging with network, layout, and crash inspection
npx react-native doctor
In development mode, shake your device or press:
// src/utils/logger.ts
export const logger = {
debug: (message: string, ...args: any[]) => {
if (__DEV__) {
console.log('🐛 DEBUG:', message, ...args);
}
},
info: (message: string, ...args: any[]) => {
if (__DEV__) {
console.info('ℹ️ INFO:', message, ...args);
}
},
warn: (message: string, ...args: any[]) => {
console.warn('⚠️ WARN:', message, ...args);
},
error: (message: string, error?: Error) => {
console.error('❌ ERROR:', message, error);
// Report to crash analytics in production
}
};Tips and tools for optimizing app performance
// Enable in development
import {Settings} from 'react-native';
Settings.set({showFPS: true});npx react-native bundle --dev false --analyze
// Optimize images
<Image
source={{uri: imageUrl}}
style={styles.image}
resizeMode="cover"
// Faster loading
progressiveRenderingEnabled={true}
// Memory optimization
defaultSource={require('./placeholder.png')}
/>You now have everything you need to start developing your React Native application. Explore the project structure and configuration options.