component lifecycle hook 必考
mounting:初始化, updating:是否更新?render() , unmounting:component销毁
![](https://img.haomeiwen.com/i11313671/a0016a035e08e53c.png)
![](https://img.haomeiwen.com/i11313671/f3d0f0627e3d2f28.png)
![](https://img.haomeiwen.com/i11313671/2f6b5ca41cae78e1.png)
![](https://img.haomeiwen.com/i11313671/20d8898a41d0da36.png)
![](https://img.haomeiwen.com/i11313671/89372469c9669dfb.png)
How to improve ur website performance?减少图片显示大小,用pure component
Pure compnent:减少加载次数,提高效率, avoid re-rendering
![](https://img.haomeiwen.com/i11313671/4b167b14de2463f9.png)
shouldcomponentUpdate() 用true or false做update判断,值相同不update
Ref:用得不多,直接访问dom,没有virtual dom 啥事了
主要整合跟第三方的类库,做表单输入时常用,this.inputref = React.createRef() / this.inputref.current.value/focus
Minxins: 概率低
![](https://img.haomeiwen.com/i11313671/a66237f022dac1d7.png)
![](https://img.haomeiwen.com/i11313671/2c63738b5101725f.png)
首先解释一下什么是Mixins,在一些大型项目中经常会存在多个组件需要使用相同的功能的情况,如果在每个组件中都重复性的加入相同的代码,那么代码的维护性将会变的非常差,Mixins的出现就是为了解决这个问题。
网友评论