What is the alternative of binding this in the constructor?

Technology CommunityCategory: ReactWhat is the alternative of binding this in the constructor?
VietMX Staff asked 3 years ago

You can use property initializers to correctly bind callbacks. This is enabled by default in create react app. You can use an arrow function in the callback. The problem here is that a new callback is created each time the component renders.