Skip to content

Commit d6df440

Browse files
committed
[change] React 16 support
Fix #364
1 parent df16c24 commit d6df440

File tree

8 files changed

+178
-166
lines changed

8 files changed

+178
-166
lines changed

docs/guides/getting-started.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ import AppHeader from './src/AppHeader';
127127
import React from 'react';
128128
import ReactNative from 'react-native';
129129

130+
// use .hydrate if hydrating a SSR app
130131
ReactNative.render(<AppHeader />, document.getElementById('react-app-header'))
131132
```
132133

jest-setup-framework.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Enzyme from 'enzyme';
2+
import Adapter from 'enzyme-adapter-react-16';
3+
4+
Enzyme.configure({ adapter: new Adapter() });

package.json

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.0.130",
44
"description": "React Native for Web",
55
"main": "dist/index.js",
6+
"module": "dist/module.js",
67
"files": [
78
"babel",
89
"dist",
@@ -29,24 +30,17 @@
2930
"test": "flow && jest"
3031
},
3132
"babel": {
32-
"presets": [
33-
"react-native"
34-
],
33+
"presets": [ "react-native" ],
3534
"plugins": [
36-
[
37-
"transform-react-remove-prop-types",
38-
{
39-
"mode": "wrap"
40-
}
41-
]
35+
[ "transform-react-remove-prop-types", { "mode": "wrap" } ]
4236
]
4337
},
4438
"jest": {
4539
"testEnvironment": "jsdom",
4640
"timers": "fake",
47-
"snapshotSerializers": [
48-
"<rootDir>/node_modules/enzyme-to-json/serializer"
49-
]
41+
"setupFiles": [ "raf/polyfill" ],
42+
"setupTestFrameworkScriptFile": "<rootDir>/jest-setup-framework.js",
43+
"snapshotSerializers": [ "enzyme-to-json/serializer" ]
5044
},
5145
"lint-staged": {
5246
"**/*.js": [
@@ -59,14 +53,14 @@
5953
"animated": "^0.2.0",
6054
"array-find-index": "^1.0.2",
6155
"babel-runtime": "^6.26.0",
62-
"create-react-class": "^15.6.0",
56+
"create-react-class": "^15.6.2",
6357
"debounce": "1.0.2",
6458
"deep-assign": "^2.0.0",
65-
"fbjs": "^0.8.14",
59+
"fbjs": "^0.8.16",
6660
"hyphenate-style-name": "^1.0.2",
6761
"inline-style-prefixer": "^3.0.8",
6862
"normalize-css-color": "^1.0.2",
69-
"prop-types": "^15.5.10",
63+
"prop-types": "^15.6.0",
7064
"react-timer-mixin": "^0.13.3"
7165
},
7266
"devDependencies": {
@@ -79,8 +73,9 @@
7973
"babel-preset-react-native": "^4.0.0",
8074
"caniuse-api": "^2.0.0",
8175
"del-cli": "^1.1.0",
82-
"enzyme": "^2.9.1",
83-
"enzyme-to-json": "^2.0.0",
76+
"enzyme": "^3.0.0",
77+
"enzyme-adapter-react-16": "^1.0.0",
78+
"enzyme-to-json": "next",
8479
"eslint": "^4.6.1",
8580
"eslint-config-prettier": "^2.4.0",
8681
"eslint-plugin-promise": "^3.5.0",
@@ -90,16 +85,17 @@
9085
"jest": "^21.1.0",
9186
"lint-staged": "^4.1.3",
9287
"prettier": "^1.7.0",
93-
"react": "^15.6.1",
94-
"react-dom": "^15.6.1",
95-
"react-test-renderer": "^15.6.1",
88+
"raf": "^3.3.2",
89+
"react": "^16.0.0",
90+
"react-dom": "^16.0.0",
91+
"react-test-renderer": "^16.0.0",
9692
"url-loader": "^0.5.9",
9793
"webpack": "^3.6.0",
9894
"webpack-bundle-analyzer": "^2.9.0"
9995
},
10096
"peerDependencies": {
101-
"react": "15.4.x || 15.5.x || 15.6.x",
102-
"react-dom": "15.4.x || 15.5.x || 15.6.x"
97+
"react": "16.x.x",
98+
"react-dom": "16.x.x"
10399
},
104100
"author": "Nicolas Gallagher",
105101
"license": "BSD-3-Clause",

src/components/TextInput/__tests__/index-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,12 @@ describe('components/TextInput', () => {
366366
);
367367

368368
// default selection is 0
369-
expect(inputDefaultSelection.node.selectionStart).toEqual(0);
370-
expect(inputDefaultSelection.node.selectionEnd).toEqual(0);
369+
expect(inputDefaultSelection.instance().selectionStart).toEqual(0);
370+
expect(inputDefaultSelection.instance().selectionEnd).toEqual(0);
371371

372372
// custom selection sets cursor at custom position
373-
expect(inputCustomSelection.node.selectionStart).toEqual(cursorLocation.start);
374-
expect(inputCustomSelection.node.selectionEnd).toEqual(cursorLocation.end);
373+
expect(inputCustomSelection.instance().selectionStart).toEqual(cursorLocation.start);
374+
expect(inputCustomSelection.instance().selectionEnd).toEqual(cursorLocation.end);
375375
});
376376
});
377377
});

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
// top-level API
33
findNodeHandle,
4+
hydrate,
45
render,
56
unmountComponentAtNode,
67

@@ -67,6 +68,7 @@ import {
6768
const ReactNative = {
6869
// top-level API
6970
findNodeHandle,
71+
hydrate,
7072
render,
7173
unmountComponentAtNode,
7274

src/module.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export { default as createElement } from './modules/createElement';
22
export { default as findNodeHandle } from './modules/findNodeHandle';
33
export { default as NativeModules } from './modules/NativeModules';
44
export { default as processColor } from './modules/processColor';
5-
export { render, unmountComponentAtNode } from 'react-dom';
5+
export { hydrate, render, unmountComponentAtNode } from 'react-dom';
66

77
// APIs
88
export { default as Animated } from './apis/Animated';

src/modules/injectResponderEventPlugin/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// based on https://github.com/facebook/react/pull/4303/files
22

3-
import EventPluginHub from 'react-dom/lib/EventPluginHub';
43
import normalizeNativeEvent from '../normalizeNativeEvent';
5-
import ResponderEventPlugin from 'react-dom/lib/ResponderEventPlugin';
6-
import ResponderTouchHistoryStore from 'react-dom/lib/ResponderTouchHistoryStore';
4+
import ReactDOM from 'react-dom';
5+
import ReactDOMUnstableNativeDependencies from 'react-dom/unstable-native-dependencies';
6+
7+
const { EventPluginHub } = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
8+
const { ResponderEventPlugin, ResponderTouchHistoryStore } = ReactDOMUnstableNativeDependencies;
79

810
const topMouseDown = 'topMouseDown';
911
const topMouseMove = 'topMouseMove';

0 commit comments

Comments
 (0)