fancyapps / ui

A library of JavaScript UI components, includes the best lightbox - Fancybox5
https://fancyapps.com/
Other
722 stars 91 forks source link

Carousel error when trying to control slides using useState in React #661

Closed Johudo closed 1 month ago

Johudo commented 1 month ago

Describe the bug

I need to render slides using state in React. I added 2 buttons: 1) adds a new slide to the end of slides list 2) deletes the first slide of list

When you click on the first button, the slide is successfully created. When I clicked the second button, an error Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. occurs.

Here's my example:

https://stackblitz.com/edit/react-ts-shhiqu?file=App.tsx

Reproduction

Click on "delete first slide" button

Additional context

No response

fancyapps commented 1 month ago

But that's to be expected, because the Carousel is written in plain JavaScript and you're using a component that's just a wrapper. You have to use API - https://fancyapps.com/carousel/api/methods/ - just the way you would use for any other non-React JavaScipt library.