mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-10 09:13:43 +08:00
Use getViewManagerConfig when available to remove warning (#28)
This commit is contained in:
committed by
Krzysztof Magiera
parent
0daa7e2ef7
commit
7ffdccd377
@@ -9,9 +9,16 @@ import {
|
||||
|
||||
let USE_SCREENS = false;
|
||||
|
||||
// UIManager[`${moduleName}`] is deprecated in RN 0.58 and `getViewManagerConfig` is added.
|
||||
// We can remove this when we drop support for RN < 0.58.
|
||||
const getViewManagerConfigCompat = name =>
|
||||
typeof UIManager.getViewManagerConfig !== 'undefined'
|
||||
? UIManager.getViewManagerConfig(name)
|
||||
: UIManager[name];
|
||||
|
||||
export function useScreens(shouldUseScreens = true) {
|
||||
USE_SCREENS = shouldUseScreens;
|
||||
if (USE_SCREENS && !UIManager['RNSScreen']) {
|
||||
if (USE_SCREENS && !getViewManagerConfigCompat('RNSScreen')) {
|
||||
console.error(
|
||||
`Screen native module hasn't been linked. Please check the react-native-screens README for more details`
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user