Disable LogBox if native module is not available

Summary: Changelog: [Internal]

Reviewed By: mmmulani

Differential Revision: D18920345

fbshipit-source-id: e5213dc9c3a1aa775138e71a8040a3472e9bbd67
This commit is contained in:
Rick Hanlon 2019-12-10 16:21:37 -08:00 коммит произвёл Facebook Github Bot
Родитель 37df2b28ad
Коммит c0eddad17b
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -14,6 +14,8 @@ const React = require('react');
import type {Registry, IgnorePattern} from './Data/YellowBoxRegistry';
import * as LogBoxData from '../LogBox/Data/LogBoxData';
import NativeLogBox from '../NativeModules/specs/NativeLogBox';
type Props = $ReadOnly<{||}>;
type State = {|
registry: ?Registry,
@ -118,6 +120,11 @@ if (__DEV__) {
}
static __unstable_enableLogBox(): void {
if (NativeLogBox == null) {
// The native module is required to enable LogBox.
return;
}
if (_isInstalled) {
throw new Error(
'LogBox must be enabled before AppContainer is required so that it can properly wrap the console methods.\n\nPlease enable LogBox earlier in your app.\n\n',

Просмотреть файл

@ -16,7 +16,7 @@ const YellowBox = require('../YellowBox');
const YellowBoxRegistry = require('../Data/YellowBoxRegistry');
const LogBoxData = require('../../LogBox/Data/LogBoxData');
const render = require('../../../jest/renderer');
jest.mock('../../NativeModules/specs/NativeLogBox', () => true);
jest.mock('../../LogBox/LogBoxNotificationContainer', () => ({
__esModule: true,
default: 'LogBoxNotificationContainer',