You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An easy way to integrate your [React](https://github.com/facebook/react) (or [Preact](https://github.com/preactjs/preact)) app into [React Native](https://github.com/facebook/react-native) app with WebView.
5
+
An easy way to integrate your [React](https://github.com/facebook/react) (or [Preact](https://github.com/preactjs/preact)/[React Native Web](https://github.com/necolas/react-native-web)) app into [React Native](https://github.com/facebook/react-native) app with WebView.
6
6
7
7
## Why?
8
8
@@ -21,8 +21,8 @@ The communication between React app and React Native app will be also simplified
21
21
22
22
## Features
23
23
24
-
- Create React (or Preact) app bundle for WebView automatically in build process of React Native
25
-
-`.js`, `.ts`, `.jsx`, `.tsx`, `.mjs` and `.cjs` will be packed into one source.
24
+
- Create React (or Preact/React Native Web) app bundle for WebView automatically in build process of React Native
25
+
-All JS modules (with or without JSX/TypeScript) will be bundled with [esbuild](https://github.com/evanw/esbuild).
26
26
-**NOTE: Only the edits in the entry file of web will invoke rebuild because of the limitation of [metro](https://github.com/facebook/metro)'s build process.**
27
27
- Handle communication between React Native and WebView with React hook style
28
28
- With `useWebViewMessage` hook, you can subscribe messages from WebView.
@@ -49,21 +49,16 @@ npm install react-dom
49
49
# Necessary only if you render Preact app in WebView
50
50
# preact >= 10.0
51
51
npm install preact
52
+
53
+
# Necessary only if you render React Native Web app in WebView
54
+
npm install react-native-web
52
55
```
53
56
54
57
### Requirements
55
58
56
-
- react >= 16.8
59
+
- react >= 16.14
57
60
- react-native >= 0.60
58
61
59
-
### Supported react-native versions
60
-
61
-
| react-native-react-bridge | react-native |
62
-
| ------------------------- | ---------------- |
63
-
| >=0.11.2 | >=0.70.0 |
64
-
| >=0.9.0 | >=0.65.0 <0.70.0 |
65
-
| 0.0.0 - 0.8.1 | <=0.64.2 |
66
-
67
62
## Usage
68
63
69
64
### 1. Fix `metro.config.js` to use babelTransformer from this library.
@@ -83,21 +78,38 @@ module.exports = {
83
78
rnrb: {
84
79
// Set `true` if you use Preact in web side.
85
80
// This will alias imports from `react` and `react-dom` to `preact/compat` automatically.
86
-
preact: true
81
+
preact: true,
82
+
// Set `true` if you use react-native-web in web side.
83
+
// This will alias imports from `react-native` to `react-native-web` automatically.
If your project at some point requires a metro configuration with additional transformers, consider making a separate `customTransformer.js` file in the project root with logic for delegating files types to the appropriate transformer, and modifying `metro.config.js` file to reference the customer transformer file. For example, if you are using `react-native-svg-transformer`, this would be your custom transformer file:
96
108
97
109
```js
98
110
// root/customTransformer.js
99
-
var reactNativeReactBridgeTransformer =require("react-native-react-bridge/lib/plugin");
100
-
var svgTransformer =require("react-native-svg-transformer");
0 commit comments