You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constReact={// React 暴露出来的 API
...
};// Note: some APIs are added with feature flags.// Make sure that stable builds for open source// don't modify the React object to avoid deopts.// Also let's not expose their names in stable builds.if(enableStableConcurrentModeAPIs){React.ConcurrentMode=REACT_CONCURRENT_MODE_TYPE;React.unstable_ConcurrentMode=undefined;}if(enableJSXTransformAPI){if(__DEV__){React.jsxDEV=jsxWithValidation;React.jsx=jsxWithValidationDynamic;React.jsxs=jsxWithValidationStatic;}else{React.jsx=jsx;// we may want to special case jsxs internally to take advantage of static children.// for now we can ship identical prod functionsReact.jsxs=jsx;}}exportdefaultReact;
在前端开发过程中,源码解读是必不可少的一个环节,我们直接进入主题,注意当前 React 版本号 16.8.6。
注意:react 包文件仅仅是 React components 的必要的、功能性的定义,它必须要结合 React render一起使用(web下是 react-dom,原生app环境下是react-native)。即 react 仅仅是定义节点与表现行为的包,具体如何渲染、如何更新这是与平台相关的,都是放在react-dom、react-native 包里的。这是我们只分析 web 环境的,即我们不会只分析 react 包文件,会结合 react 包与 react-dom、react-reconciler 及其他相关包一起分析。
React 16.8.6 使用 FlowTypes 静态类型检查器,我们需要在开发工具中支持 Fow(以 vscode 为例):
安装
Flow Language Support
插件配置
workspace/.vscode/settings.json
关于 Flow 更多请看 Flow官网。
React
首先,从 react 入口,打开 react 源码库
index.js
:进入 ./src/React。
React API
其中 React 完整内容是:
其中,React 暴露出来的 API:
这些就是 React 最主要的 API,下面 逐个击破,从应用到源码,一一吃透 React 。
附 V16 个个版本的更新内容:
React v16.0
React v16.1
React v16.2
React v16.3
React v16.4
React v16.5
React v16.6
React v16.7
React v16.8
React v16.9(~mid 2019)
The text was updated successfully, but these errors were encountered: