Im using gsap
Draggable with reactjs
ES6
, I create new draggable like this in react component componentDidUpdate
lifecycle method
import React, { Component } from 'react'
import Draggable from 'gsap/Draggable'
class DraggableContainer extends Component {
render(){
...
}
componentDidUpdate(){
const draggable = Draggable.create('.box', {
onPress: ()=>{
// currentElement suppost to contain dom element of clicked, but its undefined because 'this' is 'DraggableContainer'
const currentElement = this.target
}
})
}
}
inside method body of onPress
this.target should give current element but its undefined and this
is wrong context.
How can i access current elent inside this method?