Fix `this` binding for `onEnter` and `onLeave` callbacks