-
-
Notifications
You must be signed in to change notification settings - Fork 379
Open
Description
Describe the bug
constructor(
host: ReactiveControllerHost,
options: VirtualizerOptions<TScrollElement, TItemElement>,
) {
;(this.host = host).addController(this)
const resolvedOptions: VirtualizerOptions<TScrollElement, TItemElement> = {
...options,
onChange: (instance, sync) => {
this.host.updateComplete.then(() => this.host.requestUpdate())
options.onChange?.(instance, sync)
},
}
this.virtualizer = new Virtualizer(resolvedOptions)
}
When the constructor is called for an already connected custom element, calling addController
will cause hostConnected
to be called. This then fails because this.virtualizer
is still undefined
at that point.
Cannot read properties of undefined (reading '_didMount')
async hostConnected() {
this.cleanup = this.virtualizer._didMount()
}
Your minimal, reproducible example
Steps to reproduce
Move construction of the reactive controller in an example to connectedCallback
.
Expected behavior
Not throw an error
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
tanstack-virtual version
latest
TypeScript version
No response
Additional context
No response
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Metadata
Metadata
Assignees
Labels
No labels