← React Beginner Questions - Set 4 Q39

What is the difference between React and React Native?

React Beginner Questions - Set 4

Same component model and same React core; different renderer, so different primitives and different styling.

Example

// Web — react-dom renders HTML elements
function Card({ title }) {
  return (
    <div className="card">
      <h2>{title}</h2>
    </div>
  );
}

// Native — react-native renders platform views
import { View, Text, StyleSheet } from 'react-native';

function Card({ title }) {
  return (
    <View style={styles.card}>
      <Text style={styles.title}>{title}</Text>
    </View>
  );
}

const styles = StyleSheet.create({
  card: { padding: 16, borderRadius: 8 },
  title: { fontSize: 18, fontWeight: '600' },
});

What to notice

← Back to the question list