SolidJSS
SolidJSโ€ข3y agoโ€ข
7 replies
Mr Void

accessing store multiple time, in batch() causes infinite loop

createEffect(() => {
    batch(async () => {
        for (const card of collection.cards) {
            // some async call ...
            const tempCard = {...card}
            // updating properties
            store.cards.dispatch.updateCard(tempCard)
        }
        // ...
    })
})

Calling store's function within the loop causes infinite rendering. The batch function is inside
createEffect
.

How could I avoid an infinite loop, while still updating the objects 1 by 1 ?
Was this page helpful?