-
Notifications
You must be signed in to change notification settings - Fork 50.5k
Description
Do you want to request a feature or report a bug?
i want to report a bug.
What is the current behavior?
Array.prototype.push([]);
I get an error when i trigger element event :
Uncaught TypeError: possiblePlugin.extractEvents is not a function
at extractEvents (react-dom.development.js:704)
at runExtractedEventsInBatch (react-dom.development.js:738)
at handleTopLevel (react-dom.development.js:4203)
at batchedUpdates (react-dom.development.js:12539)
at batchedUpdates (react-dom.development.js:1941)
at dispatchEvent (react-dom.development.js:4284)
at interactiveUpdates (react-dom.development.js:12594)
at interactiveUpdates (react-dom.development.js:1960)
at dispatchInteractiveEvent (react-dom.development.js:4261)If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
What is the expected behavior?
Element Event trigger normally.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
i don't known.
** reason**
in this file : https://github.com/facebook/react/blob/master/packages/events/EventPluginRegistry.js
function recomputePluginOrdering() {
if (!eventPluginOrder) {
// Wait until an `eventPluginOrder` is injected.
return;
}
for (var pluginName in namesToPlugins) {
var pluginModule = namesToPlugins[pluginName];
var pluginIndex = eventPluginOrder.indexOf(pluginName);
!(pluginIndex > -1) ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.', pluginName) : void 0;
if (plugins[pluginIndex]) { // pluginIndex = 0 plugins[pluginIndex] = [] so containue
continue;
}
!pluginModule.extractEvents ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.', pluginName) : void 0;
plugins[pluginIndex] = pluginModule;
var publishedEvents = pluginModule.eventTypes;
for (var eventName in publishedEvents) {
!publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName) ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : void 0;
}
}
}
when use in : https://github.com/facebook/react/blob/master/packages/events/EventPluginHub.js
var possiblePlugin = plugins[i]; // when i =0 , possiblePlugin =[]
if (possiblePlugin) {
debugger
// possiblePlugin.extractEvents is undefined
var extractedEvents = possiblePlugin.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
if (extractedEvents) {
events = accumulateInto(events, extractedEvents);
}
}suggest
add Parameter check
if (plugins[pluginIndex] && typeof plugins[pluginIndex].extractEvents === 'function') { // pluginIndex = 0 plugins[pluginIndex] = [] so containue
continue;
}