Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-native-web-extended

Chion8224BSD-3-Clause0.0.7

React Native for Web

react, react-component, react-native, web

readme

React Native Web Extended

npm version

"React Native Web Extended" is a fork of React Native Web, with more components migrated from React Native.

Patch for React Native Web is available in the patch/react-native-web branch.

Get Started

Install using npm:

npm install react-native-web-extended --save

Boilerplate is coming soon.

Extended components

Currently 3 more components from React Native are added.

Navigator from React Native is re-implemented with react-router.

Usage:

render() {
  const routes = [
    {index: 0, title: 'Page 1'},
    {index: 1, title: 'Page 2'},
  ];
  return (
    <Navigator
      initialRoute={routes[0]}
      renderScene={(route, navigator) =>
        <TouchableHighlight onPress={() => {
          if (route.index === 0) {
            navigator.push(routes[1]);
          } else {
            navigator.pop();
          }
        }}>
        <Text>Hello! Route index is {route.index}, title is {route.title}</Text>
        </TouchableHighlight>
      }
      style={{padding: 100}}
    />
  );
}

Note:

  • Currently supported props: initialRoute, renderScene.
  • index key in the route object is required.
  • initialRouteStack prop is not supported, as we can't push multiple history states when the webpage loads.

TabBarIOS

Usage:

'use strict';

var React = require('react');
var ReactNative = require('react-native');
var {
  StyleSheet,
  TabBarIOS,
  Text,
  View,
} = ReactNative;

var base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg==';

class TabBarExample extends React.Component {
  static title = '<TabBarIOS>';
  static description = 'Tab-based navigation.';
  static displayName = 'TabBarExample';

  state = {
    selectedTab: 'redTab',
    notifCount: 0,
    presses: 0,
  };

  _renderContent = (color: string, pageText: string, num?: number) => {
    return (
      <View style={[styles.tabContent, {backgroundColor: color}]}>
        <Text style={styles.tabText}>{pageText}</Text>
        <Text style={styles.tabText}>{num} re-renders of the {pageText}</Text>
      </View>
    );
  };

  render() {
    return (
      <TabBarIOS
        unselectedTintColor="yellow"
        tintColor="white"
        barTintColor="darkslateblue">
        <TabBarIOS.Item
          title="Blue Tab"
          icon={{uri: base64Icon, scale: 3}}
          selected={this.state.selectedTab === 'blueTab'}
          onPress={() => {
            this.setState({
              selectedTab: 'blueTab',
            });
          }}>
          {this._renderContent('#414A8C', 'Blue Tab')}
        </TabBarIOS.Item>
        <TabBarIOS.Item
          title="Tab 2"
          icon={{uri: base64Icon, scale: 3}}
          badge={this.state.notifCount > 0 ? this.state.notifCount : undefined}
          selected={this.state.selectedTab === 'redTab'}
          onPress={() => {
            this.setState({
              selectedTab: 'redTab',
              notifCount: this.state.notifCount + 1,
            });
          }}>
          {this._renderContent('#783E33', 'Red Tab', this.state.notifCount)}
        </TabBarIOS.Item>
        <TabBarIOS.Item
          icon={require('./flux.png')}
          selectedIcon={require('./relay.png')}
          title="More"
          selected={this.state.selectedTab === 'greenTab'}
          onPress={() => {
            this.setState({
              selectedTab: 'greenTab',
              presses: this.state.presses + 1
            });
          }}>
          {this._renderContent('#21551C', 'Green Tab', this.state.presses)}
        </TabBarIOS.Item>
      </TabBarIOS>
    );
  }
}

var styles = StyleSheet.create({
  tabContent: {
    flex: 1,
    alignItems: 'center',
  },
  tabText: {
    color: 'white',
    margin: 50,
  },
});

module.exports = TabBarExample;

note:

  • Supported props for TabBarIOS : barTintColor, tintColor, unselectedTintColor
  • Supported props for TabBarIOS.Item : title, icon, selectedIcon, onPress, selected, badge

RefreshControl

Usage:

class RefreshableList extends Component {
  constructor(props) {
    super(props);
    this.state = {
      refreshing: false,
    };
  }

  _onRefresh() {
    this.setState({refreshing: true});
    fetchData().then(() => {
      this.setState({refreshing: false});
    });
  }

  render() {
    return (
      <ListView
        refreshControl={
          <RefreshControl
            refreshing={this.state.refreshing}
            onRefresh={this._onRefresh.bind(this)}
          />
        }
        ...
      >
      ...
      </ListView>
    );
  }
  ...
}

Extended APIs

Alert

Alert box with IOS theme. Vendor: Alert7. Alias: AlertIOS

Usage:

//Basic Alert
Alert.alert('Title', 'Hello!');

//Multiple Buttons
Alert.alert(
  'Alert Title',
  'My Alert Msg',
  [
    {text: 'Ask me later', onPress: () => console.log('Ask me later pressed')},
    {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'},
    {text: 'OK', onPress: () => console.log('OK Pressed')},
  ]
);

//Text Input
AlertIOS.prompt(
  'Title',
  'Enter a message',
  text => console.log("You entered "+text)
);

changelog

v2.1.0

  • Deprecate usage of <base href> as an automatic substitute for basename in useBasename. They have subtly different semantics (#94)

v2.0.2

Apr 14, 2016

  • Bugfix: Fix usage of hasOwnProperty (thanks @taion)
  • Bugfix: Fix handling of <base> without href (#262 thanks @taion)
  • Bugfix: Fix security error when frontend URL !== backend URL (#267 thanks @slorber)

v2.0.1

Mar 2, 2016

  • Bugfix: Fix stack size growth with every listenBefore listener (#225 thanks @threepointone, @taion)
  • Remove docs from npm package

v2.0.0

Feb 4, 2016

  • Bugfix: Fix search base logic with an empty query (#221)
  • Bugfix: Fail gracefully when Safari 5 security settings prevent access to window.sessionStorage (#223)

v2.0.0-rc3

Feb 3, 2016

  • Bugfix: Don't convert same-path PUSH to REPLACE when location.state changes (#179)
  • Bugfix: Re-enable browser history on Chrome iOS (#208)
  • Bugfix: Properly support location descriptors in history.createLocation (#200)

v2.0.0-rc2

Jan 9, 2016

  • Add back deprecation warnings

v2.0.0-rc1

Jan 2, 2016

  • Bugfix: Don't create empty entries in session storage (#177)

v1.17.0

Dec 19, 2015

  • Bugfix: Don't throw in memory history when out of history entries (#170)
  • Bugfix: Fix the deprecation warnings on createPath and createHref (#189)

v1.16.0

Dec 10, 2015

  • Bugfix: Silence all warnings that were introduced since 1.13 (see mjackson/react-router#2682)
  • Deprecation: Deprecate the createLocation method in the top-level exports
  • Deprecation: Deprecate the state arg to history.createLocation

v1.15.0

Dec 7, 2015

  • Feature: Accept location descriptors in createPath and createHref (#173)
  • Deprecation: Deprecate the query arg to createPath and createHref in favor of using location descriptor objects (#173)

v1.14.0

Dec 6, 2015

  • Feature: Accept objects in history.push and history.replace (#141)
  • Deprecation: Deprecate history.pushState and history.replaceState in favor of passing objects to history.push and history.replace (#168)
  • Bugfix: Disable browser history on Chrome iOS (#146)
  • Bugfix: Do not convert same-path PUSH to REPLACE if the hash has changed (#167)
  • Add ES2015 module build (#152)
  • Use query-string module instead of qs to save on bytes (#121)

v1.13.1

Nov 13, 2015

  • Fail gracefully when Safari security settings prevent access to window.sessionStorage
  • Pushing the currently active path will result in a replace to not create additional browser history entries (#43)
  • Strip the protocol and domain from <base href> (#139)

v1.13.0

Oct 28, 2015

  • useBasename transparently handles trailing slashes (#108)
  • useBasename automatically uses the value of <base href> when no basename option is provided (#94)

v1.12.6

Oct 25, 2015

  • Add forceRefresh option to createBrowserHistory that forces full page refreshes even when the browser supports pushState (#95)

v1.12.5

Oct 11, 2015

  • Un-deprecate top-level createLocation method
  • Add ability to use { pathname, search, hash } object anywhere a path can be used
  • Fix useQueries handling of hashes (#93)

v1.12.4

Oct 9, 2015

  • Fix npm postinstall hook on Windows (#62)

v1.12.3

Oct 7, 2015

  • Fix listenBefore hooks not being called unless a listen hook was also registered (#71)
  • Add a warning when we cannot save state in Safari private mode (#42)

v1.12.2

Oct 6, 2015

v1.12.1

Oct 5, 2015

  • Give location objects a key by default
  • Deprecate history.setState

v1.12.0

Oct 4, 2015

  • Add history.createLocation instance method. This allows history enhancers such as useQueries to modify location objects when creating them directly
  • Deprecate createLocation method on top-level exports

v1.11.1

Sep 26, 2015

  • Fix location.basename when location matches exactly (#68)
  • Allow transitions to be interrupted by another

v1.11.0

Sep 24, 2015

  • Add useBasename history enhancer
  • Add history.listenBefore
  • Add history.listenBeforeUnload to useBeforeUnload history enhancer
  • Deprecate (un)registerTransitionHook
  • Deprecate (un)registerBeforeUnloadHook
  • Fix installing directly from git repo