-
-
Notifications
You must be signed in to change notification settings - Fork 339
feat(solid-virtual): improve Solid adapter #790
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { | |
} from '@tanstack/virtual-core' | ||
|
||
import { | ||
createComputed, | ||
createEffect, | ||
createSignal, | ||
mergeProps, | ||
onCleanup, | ||
|
@@ -55,22 +55,19 @@ function createVirtualizerBase< | |
} | ||
|
||
const virtualizer = new Proxy(instance, handler) | ||
virtualizer.setOptions(resolvedOptions) | ||
|
||
onMount(() => { | ||
const cleanup = virtualizer._didMount() | ||
virtualizer._willUpdate() | ||
onCleanup(cleanup) | ||
}) | ||
|
||
createComputed(() => { | ||
createEffect(() => { | ||
virtualizer.setOptions( | ||
mergeProps(resolvedOptions, options, { | ||
onChange: ( | ||
instance: Virtualizer<TScrollElement, TItemElement>, | ||
sync: boolean, | ||
) => { | ||
instance._willUpdate() | ||
setVirtualItems( | ||
reconcile(instance.getVirtualItems(), { | ||
key: 'index', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also make this 'key' rather than 'index' so that it uses any custom supplied key from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it should be key |
||
|
@@ -81,6 +78,8 @@ function createVirtualizerBase< | |
}, | ||
}), | ||
) | ||
setVirtualItems([]) | ||
virtualizer._willUpdate() | ||
virtualizer.measure() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Btw the measure here looks suspicious |
||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should
batch
the set state calls together.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you suggest here?