Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native Compatibility #713

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var babelOpts = {
_moduleMap: objectAssign({}, require('fbjs/module-map'), {
'React': 'react',
'ReactDOM': 'react-dom',
'ReactNative': 'react-native',
'StaticContainer.react': 'react-static-container',
}),
};
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,12 @@
},
"dependencies": {
"babel-runtime": "5.8.24",
"fbjs": "^0.5.1",
"fbjs": "^0.7.0",
"react-static-container": "^1.0.0-alpha.1"
},
"peerDependencies": {
"babel-relay-plugin": "0.6.1",
"react": "^0.14.0",
"react-dom": "^0.14.0"
"react": "^0.14.0"
},
"devDependencies": {
"babel": "^5.8.25",
Expand All @@ -55,15 +54,15 @@
"gulp-util": "^3.0.6",
"jest-cli": "^0.8.1",
"object-assign": "^3.0.0",
"react": "^0.14.0-rc",
"react-dom": "^0.14.0-rc",
"react": "^0.14.0",
"react-dom": "^0.14.0",
"run-sequence": "^1.1.2",
"webpack": "1.11.0",
"webpack-stream": "^2.1.0"
},
"devEngines": {
"node": "4.x",
"npm": "2.x"
"node": ">=4.x",
"npm": ">=2.x"
},
"jest": {
"rootDir": "",
Expand All @@ -73,6 +72,7 @@
"persistModuleRegistryBetweenSpecs": true,
"modulePathIgnorePatterns": [
"<rootDir>/lib/",
"<rootDir>/src/(.*).native.js",
"<rootDir>/node_modules/(?!(fbjs/lib/|react/lib/))"
],
"preprocessorIgnorePatterns": [
Expand All @@ -85,6 +85,7 @@
"<rootDir>/src/"
],
"unmockedModulePathPatterns": [
"<rootDir>/src/tools/RelayUnstableBatchedUpdates.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm assuming a manual mock with module.exports = require.requireActual('...') won't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I'm not sure how to do that :( Sorry...not a Jest expert. If you point me in the right direction, happy to make the change...otherwise I defer to your decision on that.

Based on my limited knowledge of requireActual...it seems like it would work fine. But I'm not 100% certain.

"<rootDir>/node_modules/fbjs/node_modules/core-js/",
"<rootDir>/node_modules/fbjs-scripts/node_modules/core-js/",
"<rootDir>/node_modules/fbjs/node_modules/promise/",
Expand Down
2 changes: 1 addition & 1 deletion src/.flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.*/react-static-container/node_modules/.*

[include]
../node_modules/fbjs/flow/include
../node_modules/fbjs/lib
../node_modules/fbjs/node_modules/promise
../node_modules/react
../node_modules/react-static-container/lib
Expand Down
6 changes: 3 additions & 3 deletions src/container/RelayContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const GraphQLFragmentPointer = require('GraphQLFragmentPointer');
const GraphQLStoreDataHandler = require('GraphQLStoreDataHandler');
const GraphQLStoreQueryResolver = require('GraphQLStoreQueryResolver');
const React = require('React');
const ReactDOM = require('ReactDOM');
const RelayContainerComparators = require('RelayContainerComparators');
const RelayContainerProxy = require('RelayContainerProxy');
const RelayFragmentReference = require('RelayFragmentReference');
Expand All @@ -31,6 +30,7 @@ const RelayProfiler = require('RelayProfiler');
const RelayQuery = require('RelayQuery');
const RelayStore = require('RelayStore');
const RelayStoreData = require('RelayStoreData');
const unstable_batchedUpdates = require('RelayUnstableBatchedUpdates');
import type {
Abortable,
ComponentReadyStateChangeCallback,
Expand Down Expand Up @@ -80,7 +80,7 @@ var containerContextTypes = {
var storeData = RelayStoreData.getDefaultInstance();

storeData.getChangeEmitter().injectBatchingStrategy(
ReactDOM.unstable_batchedUpdates
unstable_batchedUpdates
);

/**
Expand Down Expand Up @@ -286,7 +286,7 @@ function createContainerComponent(
var mounted = this.mounted;
if (mounted) {
var updateProfiler = RelayProfiler.profile('RelayContainer.update');
ReactDOM.unstable_batchedUpdates(() => {
unstable_batchedUpdates(() => {
this.setState(partialState, () => {
updateProfiler.stop();
if (isComplete) {
Expand Down
19 changes: 19 additions & 0 deletions src/tools/RelayUnstableBatchedUpdates.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RelayUnstableBatchedUpdates
* @flow
* @typechecks
*/

'use strict';

const ReactDOM = require('ReactDOM');

module.exports = ReactDOM.unstable_batchedUpdates;
17 changes: 17 additions & 0 deletions src/tools/RelayUnstableBatchedUpdates.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule RelayUnstableBatchedUpdates
*/

'use strict';

const ReactNative = require('ReactNative');

module.exports = ReactNative.unstable_batchedUpdates;