我讀的思維在https://facebook.github.io/react/docs/thinking-in-react.html使用在反向數據流綁定(本)發生反應
陣營文檔中的文件https://facebook.github.io/react/docs/thinking-in-react.html#step-5-add-inverse-data-flow的最後一部分,我無法理解的使用綁定的(這)以及它是如何工作的。具體來說,我想明白了:
爲什麼我們需要在搜索欄組件這兩條線:
this.handleFilterTextInputChange = this.handleFilterTextInputChange.bind(this);
this.handleInStockInputChange = this.handleInStockInputChange.bind(this);
而下面的兩行FilterableProductTable組件:
this.handleFilterTextInput = this.handleFilterTextInput.bind(this);
this.handleInStockInput = this.handleInStockInput.bind(this);
會發生什麼如果我們不要這些約束?
我已經閱讀了關於JavaScript綁定函數的文檔以及我在Google上發現的反向數據流的一些示例,但仍無法獲得我的頭。
希望有人能解構數據流,並在每種情況下引用什麼this
。
閱讀此項。 https://medium.com/@rjun07a/binding-callbacks-in-react-components-9133c0b396c6#.4mthme884 – Nick
更一般地說:[使用JavaScript'綁定'方法](http://stackoverflow.com/q /218196分之2236747) –