I try to implement Babel in my javascript application but I've got a problem with a particular syntax.
Old Javascript code = this refer to li current element
var li = $('<li/>').attr('role', 'presentation')
.appendTo(navTabs).addClass( function() {
if ($(this).is(':first-child')) {
return 'active';
}
});
Babel code with arrow function = this is undefined
var li = $('<li/>').attr('role', 'presentation')
.appendTo(navTabs).addClass( ()=> {
if ($(this).is(':first-child')) { // This is undefined
return 'active';
}
});
How can I make this work with Babel arrow syntax ?