Skip to content

Commit

Permalink
BREAKING - Remove React forwarding and wrong import warnings
Browse files Browse the repository at this point in the history
Summary:
Importing `react` modules from `react-native` has been deprecated since 0.25 so I think it's safe to remove it now since everyone has migrated their code and it is now well know and documented that you import from different packages. This finishes the spring cleanup of `react-native-implementation.js` :)

**Test plan**
Tested that UIExplorer still works.
Closes #13354

Reviewed By: bvaughn

Differential Revision: D4928785

Pulled By: javache

fbshipit-source-id: 38c623c309b06b2cb5e73074833342d2745ab198
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Apr 26, 2017
1 parent 0c9b41f commit f3dbddc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 71 deletions.
32 changes: 0 additions & 32 deletions Libraries/Utilities/throwOnWrongReactAPI.js

This file was deleted.

39 changes: 0 additions & 39 deletions Libraries/react-native/react-native-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,43 +124,4 @@ const ReactNative = {
},
};

// Better error messages when accessing React APIs on ReactNative
if (__DEV__) {
const throwOnWrongReactAPI = require('throwOnWrongReactAPI');
const reactAPIs = [ 'createClass', 'Component' ];

for (const key of reactAPIs) {
Object.defineProperty(ReactNative, key, {
get() { throwOnWrongReactAPI(key); },
enumerable: false,
configurable: false,
});
}
}

// Preserve getters with warnings on the internal ReactNative copy without
// invoking them.
const ReactNativeInternal = require('ReactNative');
function applyForwarding(key) {
if (__DEV__) {
Object.defineProperty(
ReactNative,
key,
Object.getOwnPropertyDescriptor(ReactNativeInternal, key)
);
return;
}
if (ReactNative.hasOwnProperty(key)) {
// WARNING! ReactNative has read-only keys. So, if ReactNativeInternal
// has any duplicate key that ReactNative already has, this assignment
// would fail with "Attempted to assign to readonly property."
// So, if the key already exists on ReactNative, we assume that it's the
// correct module and skip re-assigning it.
return;
}
ReactNative[key] = ReactNativeInternal[key];
}
for (const key in ReactNativeInternal) {
applyForwarding(key);
}
module.exports = ReactNative;

0 comments on commit f3dbddc

Please sign in to comment.