Use getViewManagerConfig when available to remove warning (#28)

This commit is contained in:
Janic Duplessis
2018-10-08 03:06:53 -04:00
committed by Krzysztof Magiera
parent 0daa7e2ef7
commit 7ffdccd377

View File

@@ -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`
);