Skip to content

Commit bb91f4a

Browse files
rickhanloniigrabbou
authored andcommitted
Fix LogBox.ignoreAllLogs used with no argument (#29310)
Summary: When you call `LogBox.ignoreAllLogs()` it should ignore logs. This fixes a bug that made this equivalent to `LogBox.ignoreAllLogs(false)` ## Changelog [General] [Fixed] - LogBox.ignoreAllLogs() should ignore logs Pull Request resolved: #29310 Test Plan: Added tests Reviewed By: TheSavior Differential Revision: D22448436 Pulled By: rickhanlonii fbshipit-source-id: 6ba12b9d9c1f29cf3ac503946ac5ca0097425a7a
1 parent 5136fca commit bb91f4a

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Libraries/LogBox/LogBox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ if (__DEV__) {
4242
},
4343

4444
ignoreAllLogs: (value?: ?boolean): void => {
45-
LogBoxData.setDisabled(!!value);
45+
LogBoxData.setDisabled(value == null ? true : value);
4646
},
4747

4848
uninstall: (): void => {

Libraries/LogBox/__tests__/LogBox-test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ describe('LogBox', () => {
6969
expect(LogBoxData.isDisabled()).toBe(true);
7070
});
7171

72+
it('will not ignore logs for `ignoreAllLogs(false)`', () => {
73+
expect(LogBoxData.isDisabled()).toBe(false);
74+
75+
LogBox.install();
76+
77+
expect(LogBoxData.isDisabled()).toBe(false);
78+
79+
LogBox.ignoreAllLogs(false);
80+
81+
expect(LogBoxData.isDisabled()).toBe(false);
82+
});
83+
84+
it('will ignore logs for `ignoreAllLogs()`', () => {
85+
expect(LogBoxData.isDisabled()).toBe(false);
86+
87+
LogBox.install();
88+
89+
expect(LogBoxData.isDisabled()).toBe(false);
90+
91+
LogBox.ignoreAllLogs();
92+
93+
expect(LogBoxData.isDisabled()).toBe(true);
94+
});
95+
7296
it('registers warnings', () => {
7397
jest.mock('../Data/LogBoxData');
7498

0 commit comments

Comments
 (0)