Skip to content

Commit 028aaae

Browse files
committed
fix(hydration): prevent lazy hydration for updated components
1 parent 5f8314c commit 028aaae

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

packages/runtime-core/src/apiAsyncComponent.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,28 +123,28 @@ export function defineAsyncComponent<
123123

124124
__asyncHydrate(el, instance, hydrate) {
125125
let patched = false
126+
;(instance.bu || (instance.bu = [])).push(() => (patched = true))
127+
const performHydrate = () => {
128+
// skip hydration if the component has been patched
129+
if (__DEV__ && patched) {
130+
warn(
131+
`Skipping lazy hydration for component '${getComponentName(resolvedComp!) || resolvedComp!.__file}': ` +
132+
`it was updated before lazy hydration performed.`,
133+
)
134+
return
135+
}
136+
hydrate()
137+
}
126138
const doHydrate = hydrateStrategy
127139
? () => {
128-
const performHydrate = () => {
129-
// skip hydration if the component has been patched
130-
if (__DEV__ && patched) {
131-
warn(
132-
`Skipping lazy hydration for component '${getComponentName(resolvedComp!)}': ` +
133-
`it was updated before lazy hydration performed.`,
134-
)
135-
return
136-
}
137-
hydrate()
138-
}
139140
const teardown = hydrateStrategy(performHydrate, cb =>
140141
forEachElement(el, cb),
141142
)
142143
if (teardown) {
143144
;(instance.bum || (instance.bum = [])).push(teardown)
144145
}
145-
;(instance.u || (instance.u = [])).push(() => (patched = true))
146146
}
147-
: hydrate
147+
: performHydrate
148148
if (resolvedComp) {
149149
doHydrate()
150150
} else {

0 commit comments

Comments
 (0)