-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not ignore require cycle logs for RN >= 0.70 (#4214)
* Do not ignore require cycle logs for RN > 0.70 --------- Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com>
- Loading branch information
1 parent
7b6b0bc
commit 1faf8e3
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import { LogBox } from 'react-native'; | ||
|
||
interface ReactNativeVersion { | ||
major: number; | ||
minor: number; | ||
} | ||
|
||
/** | ||
* This is a workaround for using fetch on RN, this is a known issue in react-native and only generates a warning. | ||
*/ | ||
export function ignoreRequireCycleLogs(): void { | ||
LogBox.ignoreLogs(['Require cycle:']); | ||
export function ignoreRequireCycleLogs(version?: ReactNativeVersion): void { | ||
if (version && version.major === 0 && version.minor < 70) { | ||
// Do not ignore require cycle logs on React Native versions >= 0.70 | ||
// https://github.com/getsentry/sentry-react-native/issues/3484#issuecomment-1877034820 | ||
LogBox.ignoreLogs(['Require cycle:']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { LogBox } from 'react-native'; | ||
|
||
import { ignoreRequireCycleLogs } from '../../src/js/utils/ignorerequirecyclelogs'; | ||
|
||
jest.mock('react-native', () => ({ | ||
LogBox: { | ||
ignoreLogs: jest.fn(), | ||
}, | ||
})); | ||
|
||
describe('ignoreRequireCycleLogs', () => { | ||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should ignore logs for React Native version < 0.70', () => { | ||
ignoreRequireCycleLogs({ major: 0, minor: 69 }); | ||
expect(LogBox.ignoreLogs).toHaveBeenCalledWith(['Require cycle:']); | ||
}); | ||
|
||
it('should not ignore logs for React Native version 0.70', () => { | ||
ignoreRequireCycleLogs({ major: 0, minor: 70 }); | ||
expect(LogBox.ignoreLogs).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not ignore logs for React Native version > 0.70', () => { | ||
ignoreRequireCycleLogs({ major: 0, minor: 71 }); | ||
expect(LogBox.ignoreLogs).not.toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not ignore logs when no version is passed', () => { | ||
ignoreRequireCycleLogs(); | ||
expect(LogBox.ignoreLogs).not.toHaveBeenCalled(); | ||
}); | ||
}); |