Skip to content

Commit

Permalink
fix: setupRenderEffect干了啥
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolu-coding committed Apr 1, 2022
1 parent 45da9b8 commit adde1d2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/packages/runtime-core/src/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ function baseCreateRenderer(
instance.vnode = n2
}
}

// From: mountComponent
const setupRenderEffect: SetupRenderEffectFn = (
instance,
initialVNode,
Expand All @@ -1333,6 +1333,7 @@ function baseCreateRenderer(
isSVG,
optimized
) => {
// 创建更新函数
const componentUpdateFn = () => {
// 判断mounted
if (!instance.isMounted) {
Expand Down Expand Up @@ -1581,12 +1582,13 @@ function baseCreateRenderer(
}

// create reactive effect for rendering
// 创建更新机制
const effect = (instance.effect = new ReactiveEffect(
componentUpdateFn,
() => queueJob(instance.update),
instance.scope // track it in component's effect scope
))

const update = (instance.update = effect.run.bind(effect) as SchedulerJob)
update.id = instance.uid
// allowRecurse
Expand All @@ -1603,7 +1605,7 @@ function baseCreateRenderer(
// @ts-ignore (for scheduler)
update.ownerInstance = instance
}

// 首次更新视图
update()
}

Expand Down

0 comments on commit adde1d2

Please sign in to comment.