tezvyn:

📱Mobile Dev

Mobile app development across platforms

351 bites

React Native30 sec read

The React Native Gesture Handler State Machine

Think of a gesture handler as a state machine with six states. This lets you react to specific moments in a gesture's lifecycle—like `BEGAN` or `ACTIVE`—not just a single event. The footgun: ignoring the `CANCELLED` state, which can leave your UI broken.

React Native30 sec read

Expo: The New Default for React Native

Expo is the modern, production-ready default for React Native, not just a tool for prototypes. Use it for new apps to get smoother upgrades, cloud builds, and over-the-air updates out of the box.

React Native30 sec read

CI/CD for React Native: Automating App Releases

CI/CD for React Native is an assembly line for your app, taming the complexity of managing JS, Android, and iOS code. It automates builds on every push and deploys to stores. The main footgun is storing signing keys directly in your repo instead of using.

React Native31 sec read

The `act()` Utility: Syncing Tests with React's Updates

The `act()` utility ensures your tests wait for React to finish updating the DOM before you make assertions. Use it to wrap component renders and state updates. The footgun is forgetting to use `await` with an async function, which can lead to flaky tests.

React Native30 sec read

React Native & Jest: Automatic Native Module Mocking

Jest tests for React Native run in Node, not on a device, so native code won't work. The `react-native` preset automatically mocks native modules, letting you test components without a real device environment.

React Native30 sec read

React's useMemo Hook: Cache Expensive Calculations

useMemo is React's cache for expensive calculations, preventing re-computation on every render. Use it for heavy tasks like filtering large lists. The main footgun is an incomplete dependency array, which leads to stale, cached data.

React Native30 sec read

useCallback: Cache Functions Between Renders

useCallback caches a function so it's not recreated on every render. This is crucial for performance when passing callbacks as props to memoized components, preventing them from re-rendering unnecessarily.

React Native30 sec read

Flipper: A Desktop Debugger for React Native

Flipper is a desktop debugging platform for React Native, acting like Chrome DevTools for your mobile app. It connects to your local Metro server, letting you inspect component trees, view logs, and trigger reloads. The main footgun: the project is archived.

React Native30 sec read

Shared Element Transitions: Morphing Views Across Screens

Morph a component from one screen to another during navigation. By giving two components the same `sharedTransitionTag`, Reanimated animates the view's properties (size, position) between screens for a seamless transition.

React Native30 sec read

withTiming: Animate Values Over a Set Duration

withTiming is your CSS transition for React Native animations. You define a target value, a duration, and an easing curve to create predictable, time-based animations like fades or size changes.

React Native30 sec read

WebSockets: A Persistent, Two-Way Connection

Think of a WebSocket as a dedicated phone line to a server, keeping the connection open for two-way conversation. It's ideal for real-time features like live chat or streaming stock tickers.

React Native31 sec read

AbortController: Stop Fetch Requests You No Longer Need

An AbortController is a kill switch for network requests. Use it to cancel a `fetch` when a user navigates away. The main footgun is not handling the `AbortError` that `fetch` throws, which can look like a real network failure.

React Native30 sec read

FormData: The Right Way to Upload Files

FormData is your digital envelope for file uploads. It packages files and text into a `multipart/form-data` payload for `fetch`. Use it in React Native to upload images or videos. The footgun: don't set the `Content-Type` header yourself; `fetch` handles it.

React Native30 sec read

Immer: Write Mutable Code for Immutable State

Immer lets you write simple, mutable-style code to produce an immutable next state. It's essential in Redux or with React's useState to avoid complex spread operators for deep updates. The footgun: mutations are only safe inside Immer's `produce` function.

React Native30 sec read

useReducer: Manage Complex State with Predictable Actions

useReducer centralizes complex state logic. Instead of setting state directly, you "dispatch" actions describing what happened. It's ideal for state with many sub-values or when the next state depends on the previous one.

React Native30 sec read

React Context API: Avoid Prop Drilling

React Context is like a global announcement system for a component tree, letting distant children access data without passing it through every intermediate component. Use it for app-wide state like themes or user authentication.

React Native30 sec read

React Navigation State: The App's Internal Map

Think of React Navigation's state as a JS object that's the single source of truth for your app's screen history. It's essential for advanced tasks like state persistence or deep linking. The footgun: nested navigator state isn't guaranteed to exist.

React Native30 sec read

Type-Safe Navigation in React Native with TypeScript

React Navigation uses TypeScript to type-check screens and params, giving you better autocompletion. You define types for route params and augment a global navigator type so hooks like `useNavigation` understand your app's structure.

React Native33 sec read

React Native Auth Flows: Conditional Navigators

Think of your app as having two sets of maps: one for guests, one for members. React Navigation swaps the entire map when a user logs in, not just moves them. This is the key to preventing users from back-navigating to the login screen after.

React Native30 sec read

React Navigation Lifecycle: Screens Don't Unmount

Unlike the web, React Native screens don't unmount when you navigate away; they stay mounted to preserve state. This means a standard `useEffect` only runs once. To run code when a screen is shown, you must listen for the `focus` event.