mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +00:00
React native event type fixes (#10627)
* Added invariant check for native dispatching an unsupported event type This prevents a case of a silent failure when native dispatches an event that JavaScript does not know how to handle. * Added iOS direct event type 'onSnapshotReady' This is used for snapshot testing.
This commit is contained in:
1 parent
7ff922cf2a
commit
abce30f771
2 files changed
+9
No files matched your search
@@ -14,6 +14,7 @@
|
||||
var EventPropagators = require('EventPropagators');
|
||||
var SyntheticEvent = require('SyntheticEvent');
|
||||
var ReactNativeEventTypes = require('ReactNativeEventTypes');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
|
||||
var customBubblingEventTypes = ReactNativeEventTypes.customBubblingEventTypes;
|
||||
var customDirectEventTypes = ReactNativeEventTypes.customDirectEventTypes;
|
||||
@@ -44,6 +45,11 @@ var ReactNativeBridgeEventPlugin = {
|
||||
): ?Object {
|
||||
var bubbleDispatchConfig = customBubblingEventTypes[topLevelType];
|
||||
var directDispatchConfig = customDirectEventTypes[topLevelType];
|
||||
invariant(
|
||||
bubbleDispatchConfig || directDispatchConfig,
|
||||
'Unsupported top level event type "%s" dispatched',
|
||||
topLevelType,
|
||||
);
|
||||
var event = SyntheticEvent.getPooled(
|
||||
bubbleDispatchConfig || directDispatchConfig,
|
||||
targetInst,
|
||||
|
||||
@@ -284,6 +284,9 @@ const IOS_DIRECT_EVENT_TYPES = {
|
||||
topShouldStartLoadWithRequest: {
|
||||
registrationName: 'onShouldStartLoadWithRequest',
|
||||
},
|
||||
topSnapshotReady: {
|
||||
registrationName: 'onSnapshotReady',
|
||||
},
|
||||
topStateChange: {
|
||||
registrationName: 'onStateChange',
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user