diff --git a/.babelrc b/.babelrc index e918c96..24247ea 100644 --- a/.babelrc +++ b/.babelrc @@ -21,7 +21,7 @@ "transform-flow-strip-types", ], }, - // For publishing to NPM for RN + // For publishing to NPM for web "publish-web": { "presets": ["es2015", "stage-1", "react"], "plugins": [ diff --git a/package.json b/package.json index a28c791..ba0390a 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "react-native-v1": "lib-rn/react-navigation.js", "web": "lib/react-navigation.web.js" }, + "module": "lib/react-navigation.web.js", "webpack": "lib/react-navigation.web.js", "repository": { "url": "git@github.com:react-community/react-navigation.git", diff --git a/src/PlatformHelpers.js b/src/PlatformHelpers.js new file mode 100644 index 0000000..e1490cd --- /dev/null +++ b/src/PlatformHelpers.js @@ -0,0 +1,11 @@ +/* @flow */ + +export const Linking = { + addEventListener: () => {}, + removeEventListener: () => {}, + getInitialURL: () => Promise.reject('Unsupported platform'), +}; + +export const BackAndroid = { + addEventListener: () => {}, +}; diff --git a/src/PlatformHelpers.native.js b/src/PlatformHelpers.native.js new file mode 100644 index 0000000..1319640 --- /dev/null +++ b/src/PlatformHelpers.native.js @@ -0,0 +1,12 @@ +/* @flow */ + +import { + BackAndroid, + Linking, +} from 'react-native'; + +export { + BackAndroid, + Linking, +}; + diff --git a/src/createNavigationContainer.js b/src/createNavigationContainer.js index 836b484..eeaacea 100644 --- a/src/createNavigationContainer.js +++ b/src/createNavigationContainer.js @@ -1,11 +1,11 @@ /* @flow */ import React from 'react'; +import invariant from 'fbjs/lib/invariant'; import { BackAndroid, Linking, -} from 'react-native'; -import invariant from 'fbjs/lib/invariant'; +} from './PlatformHelpers'; import NavigationActions from './NavigationActions'; import addNavigationHelpers from './addNavigationHelpers'; @@ -149,10 +149,10 @@ const createNavigationContainer = ( let navigation = this.props.navigation; if (this._isStateful()) { if (!this._navigation || this._navigation.state !== this.state.nav) { - this._navigation = addNavigationHelpers({ - dispatch: this.dispatch.bind(this), - state: this.state.nav, - }); + this._navigation = addNavigationHelpers({ + dispatch: this.dispatch.bind(this), + state: this.state.nav, + }); } navigation = this._navigation; } diff --git a/src/react-navigation.web.js b/src/react-navigation.web.js index 9c0afdb..1d879a7 100644 --- a/src/react-navigation.web.js +++ b/src/react-navigation.web.js @@ -7,7 +7,6 @@ module.exports = { // Core get createNavigationContainer() { return require('./createNavigationContainer').default; }, get StateUtils() { return require('./StateUtils').default; }, - get PropTypes() { return require('./PropTypes').default; }, get addNavigationHelpers() { return require('./addNavigationHelpers').default; }, get NavigationActions() { return require('./NavigationActions').default; }, diff --git a/website/config/webpack.config.dev.js b/website/config/webpack.config.dev.js index dada9ad..466e73c 100644 --- a/website/config/webpack.config.dev.js +++ b/website/config/webpack.config.dev.js @@ -78,9 +78,6 @@ module.exports = { // https://github.com/facebookincubator/create-react-app/issues/290 extensions: ['.js', '.json', '.jsx', ''], alias: { - // Support React Native Web - // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ - 'react-native': 'react-native-web', 'react-navigation': path.resolve(__dirname, '../../'), }, }, diff --git a/website/config/webpack.config.prod.js b/website/config/webpack.config.prod.js index 14019a0..ab52ada 100644 --- a/website/config/webpack.config.prod.js +++ b/website/config/webpack.config.prod.js @@ -81,9 +81,6 @@ module.exports = { // https://github.com/facebookincubator/create-react-app/issues/290 extensions: ['.js', '.json', '.jsx', ''], alias: { - // Support React Native Web - // https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/ - 'react-native': 'react-native-web', 'react-navigation': path.resolve(__dirname, '../../'), }, }, diff --git a/website/package.json b/website/package.json index 9541dc9..a66f966 100644 --- a/website/package.json +++ b/website/package.json @@ -57,7 +57,6 @@ "react-addons-css-transition-group": "~15.3.2", "react-dom": "~15.3.2", "react-markdown": "^2.4.2", - "react-native-web": "^0.0.55", "react-navigation": "^0.0.0", "slugify": "^1.1.0" },