So I'm mapping array of objects in jsx to create categories which are sections on my page. It looks like this
{categories.map(category => (
<div className="single-category" key={category.id}>
content of single category
</div>
))}
My goal is to get array of refs.current of every single category, so I can pass it to my other component which is category navbar, where thanks to offsetTop I can compare it with window.offsetY and give corresponding category in navbar active class in CSS. I think this is possible with refs but I don't know how to do it correctly. Can anyone help? I appreciate any help :)