File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @format
8+ * @flow
9+ */
10+
11+ 'use strict' ;
12+
13+ const warning = require ( 'fbjs/lib/warning' ) ;
14+
15+ const warnedApis : { [ string ] : boolean } = { } ;
16+
17+ /**
18+ * A simple function that warns the user once if an API has been moved to
19+ * another module.
20+ *
21+ * @param {string } api - The name of the API or component that moved
22+ * @param {string } destModule - The name of the module that the API moved to
23+ * @param {string } [renamed] - Optional; name of the API in the dest module,
24+ * if it was renamed
25+ */
26+ function warnMoved ( api : string , destModule : string , renamed ?: string ) {
27+ if ( warnedApis [ api ] ) {
28+ return ;
29+ }
30+
31+ const destName = renamed != null ? renamed : api ;
32+
33+ warning (
34+ false ,
35+ `'${ api } ' has moved to another module and will be removed from 'react-native' ` +
36+ `in a future release. You can instead import it from the module '${ destModule } ':` +
37+ `\n import {${ destName } } from '${ destModule } ';` ,
38+ ) ;
39+
40+ warnedApis [ api ] = true ;
41+ }
42+
43+ module . exports = warnMoved ;
Original file line number Diff line number Diff line change 1111'use strict' ;
1212
1313const invariant = require ( 'fbjs/lib/invariant' ) ;
14+ const warnMoved = require ( 'warnMoved' ) ;
1415
1516let showedListViewDeprecation = false ;
1617let showedSwipeableListViewDeprecation = false ;
@@ -170,6 +171,7 @@ module.exports = {
170171 return require ( 'VirtualizedList' ) ;
171172 } ,
172173 get WebView ( ) {
174+ warnMoved ( 'WebView' , 'react-native-webview' ) ;
173175 return require ( 'WebView' ) ;
174176 } ,
175177
You can’t perform that action at this time.
0 commit comments