diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f733d4..33731f7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,10 +4,10 @@ We want this community to be **friendly and respectful** to each other. Please f ## Development workflow -To get started with the project, run `yarn bootsrap` in the root directory to install the required dependencies for each package: +To get started with the project, run `yarn up` in the root directory to install the required dependencies for each package: ```sh -yarn bootsrap +yarn up ``` > This project uses [`yarn`](https://classic.yarnpkg.com/) as a package manager. While it's possible to run individual commands with [`npm`](https://github.com/npm/cli), please refrain from using it, especially `npm install.` 🙅 diff --git a/packages/react-native-performance-navigation/src/ReactNavigationPerformanceView.tsx b/packages/react-native-performance-navigation/src/ReactNavigationPerformanceView.tsx index bd95252..31d652b 100644 --- a/packages/react-native-performance-navigation/src/ReactNavigationPerformanceView.tsx +++ b/packages/react-native-performance-navigation/src/ReactNavigationPerformanceView.tsx @@ -33,13 +33,13 @@ export const ReactNavigationPerformanceView = (props: Props) => { ); useEffect(() => { - if (!isStack) { + if (!isStack || !stateController.isEnabled) { return; } return addListener('transitionEnd', () => { setTransitionEnded(true); }); - }, [addListener, isStack]); + }, [addListener, isStack, stateController.isEnabled]); let shouldReportTransitionEnd = false; if (isStack && transitionEnded && transitionEndReported.current === false) { diff --git a/packages/react-native-performance-navigation/src/__tests__/ReactNavigationPerformanceView.test.tsx b/packages/react-native-performance-navigation/src/__tests__/ReactNavigationPerformanceView.test.tsx index f0408de..dd5ac1a 100644 --- a/packages/react-native-performance-navigation/src/__tests__/ReactNavigationPerformanceView.test.tsx +++ b/packages/react-native-performance-navigation/src/__tests__/ReactNavigationPerformanceView.test.tsx @@ -73,6 +73,9 @@ const createAddListenerMock = () => { describe('ReactNavigationPerformanceView', () => { beforeEach(() => { jest.clearAllMocks(); + useStateControllerMock.mockReturnValue({ + isEnabled: true, + }); }); describe('when screen is interactive on mount', () => { @@ -276,4 +279,25 @@ describe('ReactNavigationPerformanceView', () => { }); }); }); + + describe('when disabled', () => { + beforeEach(() => { + useStateControllerMock.mockReturnValue({ + isEnabled: false, + }); + }); + + it('does not add a listener with setState for transitionEnd', () => { + const {wrapper, triggerTransitionEnd} = mountReactNavigationPerformanceView({ + renderPassName: LOADING, + interactive: true, + }); + + wrapper.act(() => { + triggerTransitionEnd(); + }); + + expect(wrapper.context.navigation.addListener).not.toBeCalledWith('transitionEnd', expect.anything()); + }); + }); });