wasAsked.

What is the difference between React and React Native?

Frequently Asked (All Companies) · Role not specified · technical

Published

Year not specified · React

Community answers

Posted by wasAsked editorial collection

React and React Native share the same core ideas — components, props, state and hooks — but they target different platforms. React (React.js) - A JavaScript library for building user interfaces for the web. - Renders to the browser DOM through react-dom, using HTML elements (div, span, button) styled with CSS. - Used for single-page applications, dashboards and websites, often with frameworks such as Next.js or React Router. React Native - A framework from Meta for building native mobile apps (iOS and Android), and also desktop apps through extensions. - Renders real native UI components instead of HTML: View, Text, Image, ScrollView, FlatList, Pressable. - Styling uses JavaScript objects with a CSS-like subset (Flexbox layout), not CSS files. - Access to device features (camera, GPS, notifications, biometrics) through native modules and libraries; Expo is the recommended framework for most new projects. - The New Architecture (Fabric renderer, TurboModules and JSI) replaced the old asynchronous bridge, improving performance and native interop. Code comparison React (web): function Welcome({ name }) { return <div className="card"><h1>Hello, {name}</h1><button onClick={greet}>Greet</button></div>; } React Native: import { View, Text, Pressable, StyleSheet } from 'react-native'; function Welcome({ name }) { return ( <View style={styles.card}> <Text style={styles.title}>Hello, {name}</Text> <Pressable onPress={greet}><Text>Greet</Text></Pressable> </View> ); } const styles = StyleSheet.create({ card: { padding: 16 }, title: { fontSize: 20 } }); Key differences - Platform: web browsers vs iOS, Android (and other native platforms). - UI building blocks: HTML elements vs native components. - Styling: CSS, CSS modules, Tailwind vs StyleSheet objects with Flexbox. - Navigation: React Router or Next.js routing vs React Navigation or Expo Router. - Deployment: hosting static files or a server vs publishing to app stores (or over-the-air updates for JavaScript changes with Expo). - Platform APIs: browser APIs (localStorage, fetch, DOM) vs mobile APIs (AsyncStorage, camera, push notifications). What is shared - Same component model, JSX, hooks, state management libraries (Redux Toolkit, Zustand, TanStack Query) and business logic written in JavaScript or TypeScript. Teams often share non-UI code between web and mobile in a monorepo. When to use which - React for web applications. - React Native when you want one codebase for iOS and Android with native performance and look, especially if your team already knows React. Alternatives include Flutter or fully native Swift and Kotlin apps. Interview summary: "React builds web UIs that render to the DOM; React Native uses the same React concepts to build native mobile apps that render real platform components."

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics