react-native/Libraries/ReactNative/ReactNative.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2015-01-30 01:10:49 +00:00
/**
* Copyright (c) 2015-present, 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.
2015-01-30 01:10:49 +00:00
*
* @providesModule ReactNative
* @flow
2015-01-30 01:10:49 +00:00
*/
'use strict';
2015-01-30 01:10:49 +00:00
const ReactIsomorphic = require('ReactIsomorphic');
const ReactNativeImpl = require('ReactNativeImpl');
const warning = require('fbjs/lib/warning');
const ReactNative = { ...ReactNativeImpl };
2015-01-30 01:10:49 +00:00
const dedupe = {};
2015-01-30 01:10:49 +00:00
if (__DEV__) {
for (const key in ReactNativeImpl) {
Object.defineProperty(ReactNative, key, {
get: function() {
return ReactNativeImpl[key];
},
set: function(value) {
// Useful for hacky solutions like createExamplePage.
ReactNativeImpl[key] = value;
},
});
2015-01-30 01:10:49 +00:00
}
}
2015-01-30 01:10:49 +00:00
for (const key in ReactIsomorphic) {
ReactNative[key] = ReactIsomorphic[key];
2015-01-30 01:10:49 +00:00
if (__DEV__) {
Object.defineProperty(ReactNative, key, {
get: function() {
warning(
dedupe[key],
'ReactNative.' + key + ' is deprecated. Use React.' + key +
' from the "react" package instead.'
);
dedupe[key] = true;
return ReactIsomorphic[key];
},
set: function(value) {
// Useful for hacky solutions like createExamplePage.
ReactIsomorphic[key] = value;
},
});
2015-01-30 01:10:49 +00:00
}
}
module.exports = ReactNative;