這里也可以在render里進(jìn)行this綁定,似乎比在constructor創(chuàng)建更好理解一點(diǎn),但性能存在問(wèn)題。直接使用箭頭函數(shù)回調(diào)也會(huì)存在性能問(wèn)題
render() {
????const increaseLikes = this.increaseLikes.bind(this);
????...
}
推薦使用:在定義時(shí)使用箭頭函數(shù)綁定指向當(dāng)前詞法作用域的this。
increaseLikes = () => {
...
}
2020-10-20
看不懂