-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v-memo v-for with inline array iteration error "can't access property "el", oldVNode is undefined" #4253
Comments
|
are you sure its not the error you get on the 4th click? |
ahh yes, it shows up on 4th click, nevermind then |
the root cause is: return (_ctx, _cache) => {
return (_openBlock(), _createElementBlock(_Fragment, null, [
_createElementVNode("button", {
onClick: _cache[0] || (_cache[0] = $event => (count.value++))
}, " inc " + _toDisplayString(count.value), 1 /* TEXT */),
(_openBlock(), _createElementBlock(_Fragment, null, _renderList([1,2,3], (id, index, ___, _cached) => {
const _memo = ([count.value < 3 ? true : count.value])
+ we will lose the `dynamicChidren` (the `currentBlock` is empty) because return the cached vnode here.
if (_cached && _cached.key === id && _isMemoSame(_cached.memo, _memo)) return _cached
const _item = _createVNode(__import_1__.default, {
count: count.value,
index: index,
key: id
}, null, 8 /* PROPS */, ["count", "index"])
_item.memo = _memo
return _item
}, _cache, 1), 64 /* STABLE_FRAGMENT */))
], 64 /* STABLE_FRAGMENT */))
} |
it will be interesting to see if this also related to this root cause #4262 |
see : export function withMemo(
memo: any[],
render: () => VNode<any, any>,
cache: any[],
index: number
) {
const cached = cache[index] as VNode | undefined
if (cached && isMemoSame(cached.memo!, memo)) {
// make sure to let parent block track it when returning cached
if (isBlockTreeEnabled > 0 && currentBlock) {
currentBlock.push(cached)
}
return cached
}
const ret = render()
ret.memo = memo
return (cache[index] = ret)
} |
Version
3.2.0-beta.7
Reproduction link
sfc playground
this is inline example that does not work an raise the error
the following will work as expected ( when arr = [1,2,3] )
Steps to reproduce
open sfc
What is expected?
no error
What is actually happening?
The text was updated successfully, but these errors were encountered: