react笔记

70 阅读1分钟

1、在react的render方法里使用this.setState 会触发循环渲染,页面卡死

2、connect  withRef,因为connect是高阶组件,包裹了一层,因此想要获取组件的ref时,需要指定withRef,同时react-redux 6.0里面已经废弃了withRef改成了forwardRef

Use forwardRef to expose a ref of the wrapped component

3、react-redux的 Provider 依赖了context 和 connect原理

4、context原理