This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 没有任何副作用 | |
export const NoEffect = /* */ 0b00000000000 | |
// 用来通知在开发者工具这次更新中当前组件有更新 | |
export const PerformedWork = /* */ 0b00000000001 | |
// 需要挂载到DOM上 | |
export const Placement = /* */ 0b00000000010 | |
// 需要执行生命周期方法、 | |
export const Update = /* */ 0b00000000100 | |
// 同时拥有`Placemenet`和`Update`副作用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 现在是否有任务正在渲染,这个值在`reader`和`commit`阶段都是`true` | |
isWorking: boolean | |
// 现在是否有任务正在`commit`,在`commit`阶段为`true` | |
isCommitting: boolean | |
// 在`renderRoot`开始时设置为当前渲染的`root` | |
nextRoot: FiberRoot | |
// 在`renderRoot`开始的时候设置为当前任务的`expirationTime` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (c) Facebook, Inc. and its affiliates. | |
* | |
* This source code is licensed under the MIT license found in the | |
* LICENSE file in the root directory of this source tree. | |
* | |
* @flow | |
*/ | |
import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fiber对应一个组件需要被处理或者已经处理了,一个组件可以有一个或者多个Fiber | |
type Fiber = {| | |
// 标记不同的组件类型 | |
tag: WorkTag, | |
// ReactElement里面的key | |
key: null | string, | |
// ReactElement.type,也就是我们调用`createElement`的第一个参数 | |
elementType: any, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type BaseFiberRootProperties = {| | |
// root节点,render方法接收的第二个参数 | |
containerInfo: any, | |
// 只有在持久更新中会用到,也就是不支持增量更新的平台,react-dom不会用到 | |
pendingChildren: any, | |
// 当前应用对应的Fiber对象,是Root Fiber | |
current: Fiber, | |
// 一下的优先级是用来区分 | |
// 1) 没有提交(committed)的任务 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function finishHooks(Component, props, children, refOrContext) { | |
// This must be called after every function component to prevent hooks from | |
// being used in classes. | |
while (didScheduleRenderPhaseUpdate) { | |
// Updates were scheduled during the render phase. They are stored in | |
// the `renderPhaseUpdates` map. Call the component again, reusing the | |
// work-in-progress hooks and applying the additional updates on top. Keep | |
// restarting until no more updates are scheduled. | |
didScheduleRenderPhaseUpdate = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function useReducer(reducer, initialState, initialAction) { | |
currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); | |
workInProgressHook = createWorkInProgressHook(); | |
var queue = workInProgressHook.queue; | |
if (queue !== null) { | |
// Already have a queue, so this is an update. | |
if (isReRender) { | |
// This is a re-render. Apply the new render phase updates to the previous | |
var _dispatch2 = queue.dispatch; | |
if (renderPhaseUpdates !== null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openssl req -x509 -newkey rsa:2048 -nodes -sha256 -keyout localhost-privkey.pem -out localhost-cert.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypto from 'crypto' | |
const genRandomString = (length) => { | |
return crypto.randomBytes(Math.ceil(length / 2)) | |
.toString('hex') | |
.slice(0, length) | |
} | |
const sha512 = (password, salt) => { | |
const hash = crypto.createHmac('sha512', salt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
props: { | |
value: { | |
type: [String, Number], | |
default: '', | |
}, | |
}, | |
data() { |