25 ms·
.bind seemed to be an idiom in early React before we had the arrow functions. I also remember it coming up a bit in older frameworks like Knockout.
by quickthrower2 4y ago
.bind seemed to be an idiom in early React before we had the arrow functions. I also remember it coming up a bit in older frameworks like Knockout.
- code_runner 4y agoUsed bind a whole bunch in the knockout days and you will still find bind in a lot of todays react docs if I’m not mistaken.
- acemarke 4y agoDefinitely not "a lot" - searching the existing docs, I see a mention in the FAQ at https://reactjs.org/docs/faq-functions.html#how-do-i-bind-a-function-to-a-component-instance https://reactjs.org/docs/faq-functions.html#how-do-i-bind-a-... , but not really elsewhere. Also, the new React beta docs at https://beta.reactjs.org https://beta.reactjs.org teach function components rather than classes, and thus there's no use of `.bind()` at all.
- LocalPCGuy 4y ago.bind doesn't really have a lot to do with frameworks specifically, except maybe just that the docs may have been the first time folks were introduced to those features of the JS language. That said, I did use it a TON in the jQuery days (event handlers).