I'm currently experimenting with dynamic functionality in ReactJS and I need to determine the position of a child relative to its parent. How can I achieve this in ReactJS?
I have come across this post which discusses detecting relationships between components, but I am looking for a way to do it within a specific component structure like the example below:
<div
className={style.carousel}
>
<div
id={style.carousel_item_one}
>
carousel_item_1 // => first child, but how can I detect it?
</div>
<div
id={style.carousel_item_two}
>
carousel_item_2 // => nth child, but how can I detect it?
</div>
<div
id={style.carousel_item_three}
>
carousel_item_3 // => last child, but how can I detect it?
</div>
</div>
Any suggestions or hints would be greatly appreciated.
Thank you