Do ES2015 Classes “not autobind”?

前端 未结 5 1145
说谎
说谎 2021-02-09 04:58

I have been using React for a while now, and I have become comfortable with the concept that I must manually bind my component methods to my component instance, as React made th

5条回答
  •  萌比男神i
    2021-02-09 05:41

    I ran into problems with methods not autobinding to classes. I made a library to help: https://www.npmjs.com/package/auto-bind-inheritance

    I use it and appreciate any feedback to improve it. It was based on several other npm packages, which I believe I improved upon.

提交回复
热议问题