svelte-swipe icon indicating copy to clipboard operation
svelte-swipe copied to clipboard

Showing TypeError: undefined is not iterable

Open vinayQA opened this issue 4 years ago • 3 comments

[...swipeElements].forEach((element, i) => { ^

TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator)) at onEnd (C:\Users\sapper\dev\server\server.js:714:3) at changeItem (C:\Users_sapper_\dev\server\server.js:727:3) at Timeout.changeView [as _onTimeout] (C:\Users\sapper\dev\server\server.js:731:3) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)

vinayQA avatar Feb 05 '21 12:02 vinayQA

same problem

dioxine avatar May 08 '21 02:05 dioxine

this is because we are trying to import it in SSR environment, for example Sapper or SvelteKit. but if you import it like this:

import { onMount } from 'svelte';

let SwipeComponent;
let SwipeItemComponent;

const swipeConfig = {
	autoplay: true,
	delay: 7000,
	showIndicators: true,
	transitionDuration: 1000,
	defaultIndex: 0
};

onMount(async () => {
        const {default: swipe} = await import('svelte-swipe/src/Swipe.svelte');
        const {default: swipeItem} = await import('svelte-swipe/src/SwipeItem.svelte');
        SwipeComponent = swipe;
        SwipeItemComponent = swipeItem;
});

and use it like this:

<div class="swipe-holder">
    <svelte:component this={SwipeComponent} {...swipeConfig}>
        <svelte:component this={SwipeItemComponent}>
            <p>Slide1</p>
        </svelte:component>
        <svelte:component this={SwipeItemComponent}>
            <p>Slide2</p>
        </svelte:component>
        <svelte:component this={SwipeItemComponent}>
            <p>Slide3</p>
        </svelte:component>
    </svelte:component>
</div>

everything works! Including autoplay.

dioxine avatar May 11 '21 05:05 dioxine

why an iframe been generated? Who uses iframes still?

mylastore avatar Jul 16 '21 03:07 mylastore