Event management and arrow function (v6)
See original GitHub issued3 version 6 has made significant changes to event management. It is no longer possible to use arrow function like this:
selection.on("mouseenter", (d, i, nodes) => {
d3.select(nodes[i]);
});
This technique was used to replicate this:
selection.on("mouseenter", function() {
d3.select(this);
});
D3 6.0 migration guide made no mention of how to use arrow function for event management when this
is required.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
d3.js - Select element in drag event using arrow functions in v6
Is there a way to select the svg element within the arrow function to get a handle on the item within the drag...
Read more >Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a traditional function expression, with some semantic differences and deliberate ...
Read more >D3 6.0 migration guide - Observable
Note that event.currentTarget gives access to the element to which the listener is bound and can replace this in arrow functions:
Read more >React Component - Docs - FullCalendar
It provides a component that exactly matches the functionality of FullCalendar's ... (arg) => { // bind with an arrow function alert(arg.
Read more >Mongoose v6.8.2: Schemas
Do not declare methods using ES6 arrow functions ( => ). ... Mongoose will emit an index event on the model when indexes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah—thank you. Now I’m seeing that
currentTarget
works forstart
, but NOT fordrag
, buttoElement
does work fordrag
. Are any of these documented somewhere?@t3db0t For custom events such as d3-drag you’ll need event.sourceEvent.currentTarget.