Skip to content

Commit cb8afda

Browse files
acdliteyungsters
andauthored
Add test for #21837 (#21842)
Taken from #21837 (comment) Co-Authored-By: Timothy Yung <yungsters@fb.com> Co-authored-by: Timothy Yung <yungsters@fb.com>
1 parent f85f429 commit cb8afda

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js

+32
Original file line numberDiff line numberDiff line change
@@ -1064,4 +1064,36 @@ describe('ReactFabric', () => {
10641064
expect(TextInputState.focusTextInput).toHaveBeenCalledTimes(1);
10651065
expect(TextInputState.focusTextInput).toHaveBeenCalledWith(viewRef.current);
10661066
});
1067+
1068+
it('should no-op if calling sendAccessibilityEvent on unmounted refs', () => {
1069+
const View = createReactNativeComponentClass('RCTView', () => ({
1070+
validAttributes: {foo: true},
1071+
uiViewClassName: 'RCTView',
1072+
}));
1073+
1074+
nativeFabricUIManager.sendAccessibilityEvent.mockReset();
1075+
1076+
let viewRef;
1077+
act(() => {
1078+
ReactFabric.render(
1079+
<View
1080+
ref={ref => {
1081+
viewRef = ref;
1082+
}}
1083+
/>,
1084+
11,
1085+
);
1086+
});
1087+
const dangerouslyRetainedViewRef = viewRef;
1088+
act(() => {
1089+
ReactFabric.stopSurface(11);
1090+
});
1091+
1092+
ReactFabric.sendAccessibilityEvent(
1093+
dangerouslyRetainedViewRef,
1094+
'eventTypeName',
1095+
);
1096+
1097+
expect(nativeFabricUIManager.sendAccessibilityEvent).not.toBeCalled();
1098+
});
10671099
});

0 commit comments

Comments
 (0)