Skip to content

Commit f28c750

Browse files
rickhanloniifacebook-github-bot
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 ffa3d7f commit f28c750

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Libraries/LogBox/LogBox.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ if (__DEV__) {
4343
},
4444

4545
ignoreAllLogs: (value?: ?boolean): void => {
46-
LogBoxData.setDisabled(!!value);
46+
LogBoxData.setDisabled(value == null ? true : value);
4747
},
4848

4949
uninstall: (): void => {

Libraries/LogBox/__tests__/LogBox-test.js

+24
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)