Skip to content

Commit

Permalink
ESM LogBox
Browse files Browse the repository at this point in the history
Summary: Changelog: [General][Changed] - ESM Logbox

Reviewed By: yungsters

Differential Revision: D42202344

fbshipit-source-id: 8b09fb261c61bd3fb3ab8df66e5732046187cdd8
  • Loading branch information
lunaleaps authored and facebook-github-bot committed Jan 4, 2023
1 parent b606449 commit 9af5c33
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Libraries/Core/ExceptionsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function reportException(
}

if (__DEV__) {
const LogBox = require('../LogBox/LogBox');
const LogBox = require('../LogBox/LogBox').default;
LogBox.addException({
...data,
isComponentError: !!e.isComponentError,
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Core/InitializeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ require('./setUpSegmentFetcher');
if (__DEV__) {
require('./checkNativeVersion');
require('./setUpDeveloperTools');
require('../LogBox/LogBox').install();
require('../LogBox/LogBox').default.install();
}

require('../ReactNative/AppRegistry');
Expand Down
9 changes: 6 additions & 3 deletions Libraries/Core/__tests__/ExceptionsManager-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

'use strict';

const LogBox = require('../../LogBox/LogBox');
import LogBox from '../../LogBox/LogBox';

const ExceptionsManager = require('../ExceptionsManager');
const NativeExceptionsManager = require('../NativeExceptionsManager').default;
const ReactFiberErrorDialog = require('../ReactFiberErrorDialog').default;
Expand Down Expand Up @@ -57,9 +58,12 @@ function runExceptionsManagerTests() {
let logBoxAddException;

beforeEach(() => {
logBoxAddException = jest.fn();
jest.resetModules();
jest.mock('../../LogBox/LogBox', () => ({
addException: jest.fn(),
default: {
addException: logBoxAddException,
},
}));
jest.mock('../NativeExceptionsManager', () => {
return {
Expand All @@ -80,7 +84,6 @@ function runExceptionsManagerTests() {
);
jest.spyOn(console, 'error').mockReturnValue(undefined);
nativeReportException = NativeExceptionsManager.reportException;
logBoxAddException = LogBox.addException;
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/LogBox/LogBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,4 @@ if (__DEV__) {
};
}

module.exports = (LogBox: ILogBox);
export default (LogBox: ILogBox);
2 changes: 1 addition & 1 deletion Libraries/LogBox/__tests__/LogBox-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'use strict';

const LogBoxData = require('../Data/LogBoxData');
const LogBox = require('../LogBox');
const LogBox = require('../LogBox').default;

declare var console: any;

Expand Down
3 changes: 2 additions & 1 deletion Libraries/YellowBox/YellowBoxDeprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import type {IgnorePattern} from '../LogBox/Data/LogBoxData';

const LogBox = require('../LogBox/LogBox');
import LogBox from '../LogBox/LogBox';

const React = require('react');

type Props = $ReadOnly<{||}>;
Expand Down
3 changes: 2 additions & 1 deletion Libraries/YellowBox/__tests__/YellowBoxDeprecated-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

'use strict';

const LogBox = require('../../LogBox/LogBox');
import LogBox from '../../LogBox/LogBox';

const YellowBox = require('../YellowBoxDeprecated');

describe('YellowBox', () => {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ module.exports = {
return require('./Libraries/Linking/Linking');
},
get LogBox(): LogBox {
return require('./Libraries/LogBox/LogBox');
return require('./Libraries/LogBox/LogBox').default;
},
get NativeDialogManagerAndroid(): NativeDialogManagerAndroid {
return require('./Libraries/NativeModules/specs/NativeDialogManagerAndroid')
Expand Down

0 comments on commit 9af5c33

Please sign in to comment.