K
K
KononovD2019-06-05 18:18:30
React
KononovD, 2019-06-05 18:18:30

How to make a carousel in React?

Hello, there is a problem that is easier to state with a picture:

spoiler
5cf7dc1327c08808339978.jpeg5cf7dc30ca0ca280503849.jpeg

I have a variable that points to an element in an array that should be displayed. I understand that because of this index, when the component is re-rendered, a shift occurs, but I don’t know how to fix this.
if it would be possible to somehow insert the necessary elements with some kind of insertBefore() at the beginning and appendChild() at the end - it would be much easier)
p.s. maybe, even most likely, the idea of ​​​​changing the array of slides is a bad idea, but I didn’t think of how to do otherwise

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question