mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
d016766303
Summary: ## Context Default events are only attached to the first-loaded component. ## Problem This complicates SVC == NVC reconciliation: - The Static ViewConfigs of all components contain these default events. - The native ViewConfig of *only the first component that loads* has these default events. ## FAQ **Question:** If default events were only attached to the first loaded component, how come all components could emit these default events? In short, if one component declares an event, React Native can dispatch that event to **all** components: 1. The ReactFabric-dev renderer invokes [ReactNativeViewConfigRegistry.get](https://fburl.com/code/468l3zp7) to get the ViewConfig of a component. 2. ReactNativeViewConfigRegistry.get inserts a component's the Bubbling/Direct events into [two **global** maps: ReactNativeViewConfigRegistry.customBubblingEventTypes, ReactNativeViewConfigRegistry.customDirectEventTypes](https://www.internalfb.com/code/fbsource/[00ccc3c7a1b76e55986a6d753b8748327397e5eb]/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js?lines=20-34%2C57-72%2C117). 3. When the ReactFabric-dev renderer needs to dispatch events, it just [does a lookup on these two **global** maps](https://www.internalfb.com/code/fbsource/[2de1e1d59f6e0316868a6c4d9bca5fe673210106]/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.js?lines=2426%2C2439-2440) to create/dispatch the SyntheticEvents. **Question:** Should we gate these changes? This change should be safe to land without gating. This diff just creates duplicate entries for bubbling/direct events across components, which should [just get ignored by ReactNativeViewConfigRegistry](https://www.internalfb.com/code/fbsource/[4c57b02a0edccfd8a5fcc3a63ed2dd622efea320]/xplat/js/react-native-github/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js?lines=42%2C57-72%2C117). Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D33303417 fbshipit-source-id: fa777ca92e57b82eafb94f7d05ef4064ed5060ed