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.

Minor: constructor name for SyntheticEvent subclasses

See original GitHub issue

This is a risibly minor issue, but I wanted to bring it up in case there’s a super easy fix to it. In older versions of React, doing e.constructor.name on synthetic events would report the constructor class’ name, but right now it reports a generic Class, due to the way SyntheticEvent is extended:

https://github.com/facebook/react/blob/ae14317d6810d5b07d01308a2116a707e5e09983/packages/events/SyntheticEvent.js#L219-L238

I’m in the process of bringing this small tool up to date, and I’ve upgraded from React 15.4 to React 16.4, and I get lots of Class logs: https://danburzo.github.io/input-methods/

(The workaround is to just assume Class = some subclass of SyntheticEvent, but it would be nice to have a more precise name?)

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
gaearoncommented, Jun 18, 2018

I’m curious what value it provides over just using the event type.

e.nativeEvent.constructor.name might also be helpful unless you’re specifically debugging React itself

0reactions
danburzocommented, Jun 18, 2018

If anything easy comes to mind, I’ll make a PR, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntheticEvent - React
This reference guide documents the SyntheticEvent wrapper that forms part of React's Event System. See the Handling Events guide to learn more.
Read more >
W3C DOM4
The DOMError( name , message ) constructor must return a new DOMError ... Dispatches a synthetic event event to target and returns true...
Read more >
React Flashcards - Quizlet
A React component is a function or a class which optionally accepts input and ... Because React is a small library focused on...
Read more >
What does calling super() in a React constructor do?
super () will call the constructor of its parent class. This is required when you need to access some variables from the parent...
Read more >
reactstrap - UNPKG
node_modules/react-dom/lib/SyntheticEvent.js",". ... { throw new TypeError('Cannot call a class as a function'); } }\n\nfunction _inherits(subClass, ...
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