From 32f454de667b52c41963245a95c9459abde69779 Mon Sep 17 00:00:00 2001 From: Nicolas Gallagher Date: Fri, 23 Dec 2016 12:28:39 +0000 Subject: [PATCH] [change] add Platform and Touchable to 'core' module --- docs/guides/react-native.md | 44 ++++++++++++++++++++++++++++++++----- docs/guides/rendering.md | 5 +++-- src/core.js | 10 +++++++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/docs/guides/react-native.md b/docs/guides/react-native.md index 30714924..1210bef7 100644 --- a/docs/guides/react-native.md +++ b/docs/guides/react-native.md @@ -27,14 +27,48 @@ the `url-loader` to the webpack config: module.exports = { // ... module: { - loaders: { - test: /\.(gif|jpe?g|png|svg)$/, - loader: 'url-loader', - query: { name: '[name].[hash:16].[ext]' } - } + loaders: [ + { + test: /\.(gif|jpe?g|png|svg)$/, + loader: 'url-loader', + query: { name: '[name].[hash:16].[ext]' } + } + ] } +}; ``` +## Dependencies + +Many OSS React Native packages are not compiled to ES5 before being published. +This can result in webpack build errors. To avoid this issue you should +configure webpack (or your bundler of choice) to run +`babel-preset-react-native` over the necessary `node_module`. For example: + +```js +// webpack.config.js + +module.exports = { + // ... + module: { + loaders: [ + { + // transpile to ES5 + test: /\.jsx?$/, + include: [ + path.resolve(__dirname, 'src'), + path.resolve(__dirname, 'node_modules/react-native-something') + ], + loader: 'babel-loader', + query: { cacheDirectory: true } + } + ] + } +}; +``` + +Please refer to the webpack documentation for more information. + ## Web-specific code Minor platform differences can use the `Platform` module. diff --git a/docs/guides/rendering.md b/docs/guides/rendering.md index 13d668e2..6fe5c1b9 100644 --- a/docs/guides/rendering.md +++ b/docs/guides/rendering.md @@ -16,8 +16,9 @@ module.exports = { } ``` -The `react-native-web` package also includes a `core` module that exports only -`ReactNative`, `Image`, `StyleSheet`, `Text`, `TextInput`, and `View`. +The `react-native-web` package also includes a `core` module that exports a +subset of modules: `ReactNative`, `I18nManager`, `Platform`, `StyleSheet`, +`Image`, `Text`, `TextInput`, `Touchable`, and `View`. ```js // webpack.config.js diff --git a/src/core.js b/src/core.js index 67e056c5..6a8ff5a4 100644 --- a/src/core.js +++ b/src/core.js @@ -6,12 +6,17 @@ ReactDefaultInjection.inject(); // APIs import I18nManager from './apis/I18nManager'; +import Platform from './apis/Platform'; import StyleSheet from './apis/StyleSheet'; // components import Image from './components/Image'; import Text from './components/Text'; import TextInput from './components/TextInput'; +import Touchable from './components/Touchable/Touchable'; +import TouchableHighlight from './components/Touchable/TouchableHighlight'; +import TouchableOpacity from './components/Touchable/TouchableOpacity'; +import TouchableWithoutFeedback from './components/Touchable/TouchableWithoutFeedback'; import View from './components/View'; // modules @@ -24,11 +29,16 @@ const ReactNativeCore = { unmountComponentAtNode, // APIs I18nManager, + Platform, StyleSheet, // components Image, Text, TextInput, + Touchable, + TouchableHighlight, + TouchableOpacity, + TouchableWithoutFeedback, View };