Full answer
React is a library for describing UI as a function of state. A renderer turns that description into output. react-dom renders to the browser DOM. React Native provides a renderer that creates native views on the device. Your component model is identical: function components, props, useState, useEffect, context.
What changes are the primitives. There is no div, span, button or img. You use View for containers, Text for all text (text must be inside Text), Image, Pressable or Touchable components for taps, and ScrollView or FlatList for scrolling lists. There is no CSS file. Styles are objects passed to style, created with StyleSheet.create, laid out with Flexbox where column is the default direction. There is no DOM, so no document, window or localStorage. You use platform APIs and libraries such as AsyncStorage instead.
Navigation also differs. Instead of URLs and the browser history, apps use React Navigation or Expo Router with a stack of screens.
Sharing code: business logic, custom hooks, state stores, API clients, validation and types can live in a shared package. UI components are written per platform, or you use a library such as React Native for Web or a universal framework like Expo, which renders React Native primitives on the web.
Modern React Native uses the New Architecture (the JSI and Fabric renderer), which lets React features such as concurrent rendering and Suspense work on mobile. Most teams start with Expo for tooling.
The example runs React Native primitives in a web environment through React Native for Web, with a shared hook.
import { useState } from 'react';
import { Pressable, StyleSheet, Text, View } from 'react-native';
function useCounter(initial = 0) {
const [count, setCount] = useState(initial);
return { count, increment: () => setCount((c) => c + 1) };
}
export default function CounterScreen() {
const { count, increment } = useCounter();
return (
<View style={styles.container}>
<Text style={styles.title}>Taps: {count}</Text>
<Pressable onPress={increment} accessibilityRole="button">
<Text>Tap me</Text>
</Pressable>
</View>
);
}
const styles = StyleSheet.create({
container: { padding: 16 },
title: { fontSize: 20 },
});useCounter is plain React and could be shared with a web app unchanged. The screen uses React Native components. This check ran it on the web through react-native-web (an alias for react-native), which shows the code works but is not a test on a device or the native renderer. Rendered result: <div class="css-view-g5y9jx r-padding-nsbfu8"><div dir="auto" class="css-text-146c3p1 r-fontSize-adyw6z">Taps: 0</div><button role="button" tabindex="0" class="css-view-g5y9jx r-cursor-1loqt21 r-touchAction-1otgn73" type="button"><div dir="auto" class="css-text-146c3p1">Tap me</div></button></div>
Key points
- Same React core, different renderer and primitives.
- Use View, Text and Pressable instead of div, span and button. All text sits inside Text.
- Styles are JavaScript objects with Flexbox, not CSS files.
- Share hooks, logic and API code. Write or adapt the UI per platform.
- Expo and the New Architecture are the common modern setup.
Common mistakes
- Using div, span or CSS class names in React Native.
- Putting bare text outside a Text component.
- Using window, document or localStorage in code meant for both platforms.
- Expecting CSS features such as cascading or pseudo-classes in StyleSheet.
- Sharing UI components between web and native without a plan.
Follow-ups
- How does FlatList differ from rendering a mapped array in a ScrollView?
- What does Expo add to a React Native project?
- What is the New Architecture and what does it change for developers?
Tips
- Open with "same React, different renderer". It frames the answer correctly.
- Name the primitives and say what is shareable.
- Mention Expo, since most new projects start there.