diff --git a/src/swipe/index.tsx b/src/swipe/index.tsx index d69fbc1e7..caf4722da 100644 --- a/src/swipe/index.tsx +++ b/src/swipe/index.tsx @@ -282,7 +282,9 @@ export default createComponent({ const rect = useRect(root); - active = Math.min(children.length - 1, active); + if (count.value) { + active = Math.min(count.value - 1, active); + } state.rect = rect; state.swiping = true; @@ -430,10 +432,7 @@ export default createComponent({ (value) => initialize(+value) ); - watch( - () => children.length, - () => initialize(state.active) - ); + watch(count, () => initialize(state.active)); watch( () => props.autoplay, diff --git a/src/swipe/test/__snapshots__/index.spec.js.snap b/src/swipe/test/__snapshots__/index.spec.js.snap index 7a762ba3b..68f97cce8 100644 --- a/src/swipe/test/__snapshots__/index.spec.js.snap +++ b/src/swipe/test/__snapshots__/index.spec.js.snap @@ -32,6 +32,44 @@ exports[`should not allow to drag swipe when touchable is false 1`] = ` `; +exports[`should render dynamic SwipeItem correctly 1`] = ` +