這里也可以在render里進行this綁定,似乎比在constructor創建更好理解一點,但性能存在問題。直接使用箭頭函數回調也會存在性能問題
render() {
????const increaseLikes = this.increaseLikes.bind(this);
????...
}
推薦使用:在定義時使用箭頭函數綁定指向當前詞法作用域的this。
increaseLikes = () => {
...
}
render() {
????const increaseLikes = this.increaseLikes.bind(this);
????...
}
推薦使用:在定義時使用箭頭函數綁定指向當前詞法作用域的this。
increaseLikes = () => {
...
}
2020-02-10
舉報
2020-10-20
看不懂