What is React Native and how does it differ from React?
React Native is a framework for building native mobile applications (iOS and Android)
using React and JavaScript. While React is for web development, React Native allows you
to create mobile apps with a similar paradigm but using native components (e.g., <View>
instead of <div>).
Key Differences:
- React: Builds for the web, rendering HTML and managing DOM.
- React Native: Builds for mobile, using native components and APIs for interaction
with mobile devices (camera, geolocation, etc.).
Example in React Native:
import { Text, View } from 'react-native';
function App() {
return (
<View>
<Text>Hello, React Native!</Text>
</View>
);
}
In React Native, the components map to native UI elements, such as <Text> for text,
<View> for containers, and <Button> for buttons.