diff --git a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js index 4c5bea872bbd8..6b776c085fd40 100644 --- a/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js @@ -1064,4 +1064,36 @@ describe('ReactFabric', () => { expect(TextInputState.focusTextInput).toHaveBeenCalledTimes(1); expect(TextInputState.focusTextInput).toHaveBeenCalledWith(viewRef.current); }); + + it('should no-op if calling sendAccessibilityEvent on unmounted refs', () => { + const View = createReactNativeComponentClass('RCTView', () => ({ + validAttributes: {foo: true}, + uiViewClassName: 'RCTView', + })); + + nativeFabricUIManager.sendAccessibilityEvent.mockReset(); + + let viewRef; + act(() => { + ReactFabric.render( + { + viewRef = ref; + }} + />, + 11, + ); + }); + const dangerouslyRetainedViewRef = viewRef; + act(() => { + ReactFabric.stopSurface(11); + }); + + ReactFabric.sendAccessibilityEvent( + dangerouslyRetainedViewRef, + 'eventTypeName', + ); + + expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled(); + }); });