-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deprecation warnings for split of the react and react-native pack…
…ages Summary:This adds deprecation warnings that correspond to what React 0.14 did for the web. I.e. `React.render` -> `ReactNative.render` but also `ReactNative.createClass` -> `React.createClass`. This hopefully means that it will become easier and more idiomatic to write components that are decoupled from the react-native package. It will be clear when you take on react-native as a dependency such as when using findNodeHandle. This codemod is a little more invasive for React Native because the common stuff often used the `react-native` package. For web only the uncommon stuff needed to move. Reviewed By: spicyj Differential Revision: D3148860 fb-gh-sync-id: d87628d2089a2e012ad6ad50dd0a20ccec5e6c45 fbshipit-source-id: d87628d2089a2e012ad6ad50dd0a20ccec5e6c45
- Loading branch information
1 parent
a80dd9a
commit 2eafcd4
Showing
4 changed files
with
145 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** | ||
* 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. | ||
* | ||
* @providesModule ReactNativeImpl | ||
* @flow | ||
*/ | ||
'use strict'; | ||
|
||
// Require ReactNativeDefaultInjection first for its side effects of setting up | ||
// the JS environment | ||
var ReactNativeDefaultInjection = require('ReactNativeDefaultInjection'); | ||
|
||
var ReactCurrentOwner = require('ReactCurrentOwner'); | ||
var ReactElement = require('ReactElement'); | ||
var ReactInstanceHandles = require('ReactInstanceHandles'); | ||
var ReactNativeMount = require('ReactNativeMount'); | ||
var ReactUpdates = require('ReactUpdates'); | ||
|
||
var findNodeHandle = require('findNodeHandle'); | ||
|
||
ReactNativeDefaultInjection.inject(); | ||
|
||
var render = function( | ||
element: ReactElement, | ||
mountInto: number, | ||
callback?: ?(() => void) | ||
): ?ReactComponent { | ||
return ReactNativeMount.renderComponent(element, mountInto, callback); | ||
}; | ||
|
||
var ReactNative = { | ||
hasReactNativeInitialized: false, | ||
findNodeHandle: findNodeHandle, | ||
render: render, | ||
unmountComponentAtNode: ReactNativeMount.unmountComponentAtNode, | ||
|
||
/* eslint-disable camelcase */ | ||
unstable_batchedUpdates: ReactUpdates.batchedUpdates, | ||
/* eslint-enable camelcase */ | ||
|
||
unmountComponentAtNodeAndRemoveContainer: ReactNativeMount.unmountComponentAtNodeAndRemoveContainer, | ||
}; | ||
|
||
// Inject the runtime into a devtools global hook regardless of browser. | ||
// Allows for debugging when the hook is injected on the page. | ||
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
if ( | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') { | ||
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ | ||
CurrentOwner: ReactCurrentOwner, | ||
InstanceHandles: ReactInstanceHandles, | ||
Mount: ReactNativeMount, | ||
Reconciler: require('ReactReconciler'), | ||
TextComponent: require('ReactNativeTextComponent'), | ||
}); | ||
} | ||
|
||
module.exports = ReactNative; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OSS react native needs this to be `require('fbjs/lib/warning').
OSS trunk got broken :(
https://circleci.com/gh/facebook/react-native/4990