File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ type RNTopLevelEventType =
2020
2121export opaque type DOMTopLevelEventType = string ;
2222
23+ // Do not uses the below two methods directly!
24+ // Instead use constants exported from DOMTopLevelEventTypes in ReactDOM.
25+ // (It is the only module that is allowed to access these methods.)
26+
2327export function unsafeCastStringToDOMTopLevelType (
2428 topLevelType : string ,
2529) : DOMTopLevelEventType {
Original file line number Diff line number Diff line change @@ -16,15 +16,12 @@ import {
1616import getVendorPrefixedEventName from './getVendorPrefixedEventName' ;
1717
1818/**
19- * To identify top level events in react-dom, we use constants defined by this
20- * module. Those are completely opaque to every other module but we rely on them
21- * being the raw DOM event names inside this module. This allows us to build a
22- * very efficient mapping from top level identifiers to the raw event type.
23- *
24- * The use of an `opaque` flow type makes sure that we can only access the value
25- * of a constant in this module.
19+ * To identify top level events in ReactDOM, we use constants defined by this
20+ * module. This is the only module that uses the unsafe* methods to express
21+ * that the constants actually correspond to the browser event names. This lets
22+ * us save some bundle size by avoiding a top level type -> event name map.
23+ * The rest of ReactDOM code should import top level types from this file.
2624 */
27-
2825export const TOP_ABORT = unsafeCastStringToDOMTopLevelType ( 'abort' ) ;
2926export const TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType (
3027 getVendorPrefixedEventName ( 'animationend' ) ,
You can’t perform that action at this time.
0 commit comments