react-book
react-book copied to clipboard
[Section I] - general question about usage on bind()
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!
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.