Skip to content

Commit f9a708a

Browse files
committed
fix: svelte batch update
1 parent 7309ddb commit f9a708a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/collectionview/svelte/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { profile } from '@nativescript/core/profiling';
33
import { ContentView, LayoutBase, StackLayout, ViewBase } from '@nativescript/core/ui';
44
import { NativeViewElementNode, TemplateElement, ViewNode, createElement, registerElement } from 'svelte-native/dom';
55
import { flush } from 'svelte/internal';
6-
import { CollectionView } from '..'
6+
import { CollectionView } from '..';
77

88
declare module '@nativescript/core/ui/core/view-base' {
99
interface ViewBase {
@@ -72,7 +72,7 @@ export default class CollectionViewViewElement extends NativeViewElementNode<Col
7272
const builder = (parentView, props: any) => {
7373
(nativeEl as any).__SvelteComponent__ = new componentClass({
7474
target: parentView,
75-
props,
75+
props
7676
});
7777
};
7878
// in svelte we want to add the wrapper as a child of the collectionview ourselves
@@ -133,8 +133,10 @@ export default class CollectionViewViewElement extends NativeViewElementNode<Col
133133
// ensure we dont do unnecessary tasks if index did not change
134134
// console.log('updateListItem', args.index, _view.__CollectionViewCurrentIndex__);
135135
_view.__CollectionViewCurrentIndex__ = args.index;
136-
componentInstance.$set(props);
137-
flush(); // we need to flush to make sure update is applied right away
136+
_view._batchUpdate(() => {
137+
componentInstance.$set(props);
138+
flush(); // we need to flush to make sure update is applied right away
139+
});
138140
}
139141
}
140142

0 commit comments

Comments
 (0)