react 笔记

108 阅读1分钟

component

只是承载信息

componentDumy 是什么

pureCompomentProtoype.coustructor = PureComponent 指向自己实现继承
isPureReactComponent

Ref

stringRef
function Component 无实例,无this对象,无生命周期方法
forWardRef :type

react核心

更新到结束流程

组件状态

readonly state 只是可读 无状态组件:展示组件 展示组件内部的state可以被写为纯函数

context

createContext
不利于组件复用
Parent.childContextTypes

provider 提供方
consumer 使用方

Hooks

useState: ReactCurrentOwner.currentDispatcher

创建和渲染

创建过程中无react实例,只是将方法传入。
只有在渲染构建dom 的过程中在创建实例

React.Children

React.Children.map(props.children,c=>[c,[c,c]]) 展开称为一层数组,平铺
mapChildren 递归过程

React

本身只是创建节点、类型、ref、key 等,并未做任何的操作、没有任逻辑