Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-web

Package Overview
Dependencies
Maintainers
0
Versions
355
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-web

React Native for Web

  • 0.19.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
663K
increased by5.24%
Maintainers
0
Weekly downloads
 
Created

What is react-native-web?

The react-native-web package allows you to use React Native components and APIs to build web applications. It provides a way to write a single codebase that can run on both mobile and web platforms, leveraging the same React Native components.

What are react-native-web's main functionalities?

Cross-Platform Components

This feature allows you to use React Native components like View and Text to build web applications. The code sample demonstrates a simple app that displays 'Hello, world!' using React Native components.

import { View, Text } from 'react-native';
import { AppRegistry } from 'react-native-web';

const App = () => (
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    <Text>Hello, world!</Text>
  </View>
);

AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', { initialProps: {}, rootTag: document.getElementById('app') });

StyleSheet for Web

This feature allows you to use the StyleSheet API from React Native to style your web components. The code sample shows how to create and apply styles using StyleSheet.

import { StyleSheet, View, Text } from 'react-native';
import { AppRegistry } from 'react-native-web';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
});

const App = () => (
  <View style={styles.container}>
    <Text style={styles.welcome}>Welcome to React Native Web!</Text>
  </View>
);

AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', { initialProps: {}, rootTag: document.getElementById('app') });

Event Handling

This feature allows you to handle events such as button presses using React Native's event handling system. The code sample demonstrates a button that shows an alert when pressed.

import { View, Button, Alert } from 'react-native';
import { AppRegistry } from 'react-native-web';

const App = () => (
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
    <Button
      title="Press me"
      onPress={() => Alert.alert('Button pressed!')}
    />
  </View>
);

AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', { initialProps: {}, rootTag: document.getElementById('app') });

Other packages similar to react-native-web

Keywords

FAQs

Package last updated on 17 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc