react-book icon indicating copy to clipboard operation
react-book copied to clipboard

[Section I] - general question about usage on bind()

Open JESii opened this issue 7 years ago • 1 comments

In your code, you use the form function.bind(null, callback), whereas the examples in the React documentation (e.g., here and here) just use function.bind(callback).

Why is that? This is most likely just my lack of JavaScript knowledge; however, I would like to understand it better and it might help other readers? Thanks!

JESii avatar May 23 '17 10:05 JESii

It's how the specification works. The first parameter accepts the context and the second parameter(s).

You can see bits like this.handleLoginClick = this.handleLoginClick.bind(this); in the React docs at constructors and they leave parameters unbound there.

bebraw avatar May 23 '17 10:05 bebraw