question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error: possiblePlugin.extractEvents is not a function

See original GitHub issue

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);
      }
    }

image

suggest add Parameter check

    if (plugins[pluginIndex] && typeof plugins[pluginIndex].extractEvents === 'function') { // pluginIndex = 0  plugins[pluginIndex] = [] so containue
      continue;
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
gaearoncommented, Jun 19, 2018

We’d have to do this in every single function that uses arrays. That’s not really acceptable.

2reactions
philipp-spiesscommented, Jun 19, 2018
Array.prototype.push([]);

Will mutate the prototype of all arrays in your application and as such you are effectively breaking all array operations. This is not a React issue. React requires the Array prototype to be in tact.

// If you run this anywhere:
Array.prototype.push([]);
// Every array will be broken
const emptyArray = [];
// This returns `[]` although it should be undefined.
emptyArray[0]; 

We recommend that you avoid modifications to global prototypes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
reactstrap - UNPKG
A value is considered array-like if it's\n * not a function and has a `value.length` ... n // `item` might not exist if...
Read more >
React package for working with the DOM. - GitHub Pages
Target container is not a DOM element. ... extractEvents = function (topLevelType, targetInst, nativeEvent, nativeEventTarget) { return ...
Read more >
https://git.progress-linux.org/packages/fuchur/fir...
extractEvents ) { { throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + pluginName + "` does not.
Read more >
react-dom-dev.js - searchcode
Because React wraps all user-provided 78 // functions in ... But because the error happens in a different 90 // event loop context,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found