Skip to content

Commit d758960

Browse files
committed
Tweak comments
1 parent 025d867 commit d758960

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

packages/events/TopLevelEventTypes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ type RNTopLevelEventType =
2020

2121
export 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+
2327
export function unsafeCastStringToDOMTopLevelType(
2428
topLevelType: string,
2529
): DOMTopLevelEventType {

packages/react-dom/src/events/DOMTopLevelEventTypes.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ import {
1616
import 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-
2825
export const TOP_ABORT = unsafeCastStringToDOMTopLevelType('abort');
2926
export const TOP_ANIMATION_END = unsafeCastStringToDOMTopLevelType(
3027
getVendorPrefixedEventName('animationend'),

0 commit comments

Comments
 (0)