taofed / react-web

A framework for building web apps with React Native compatible API.
Other
3.36k stars 448 forks source link
react react-native

:warning: Use react-native-web instead.

react-web

React Web 中文 npm version

A library for building web apps with React Native compatible API.

Getting Started

Install

npm install --save react-web

Add Webpack configuration

Inside your webpack configuration, alias the react-native package to the react-web package:

// webpack.config.js

module.exports = {
  resolve: {
    alias: {
      'react-native': 'react-web'
    }
  }
}

Write your application with React Native API

import React, {Component} from 'react';
import {AppRegistry, StyleSheet, Text, View, Platform} from 'react-native';

class App extends Component {
  render() {
    return (
      <View style={styles.box}>
        <Text style={styles.text}>Hello, world!</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  box: {padding: 10},
  text: {fontWeight: 'bold'}
});

AppRegistry.registerComponent('App', () => App);

if (Platform.OS === 'web') {
  AppRegistry.runApplication('App', { rootTag: document.getElementById('app') });
}

React Native Compatible

Project Dependencies

License

React Web is BSD licensed.