Skip to content
Advertisement

Tag: use-state

Is there a way to set the first element in this .map method to a default class on load?

I am currently rendering three buttons using a .map method in React. The buttons are being pulled from an array in a useState. When clicked, the buttons have a .active class added to them. How can I set the first element to have the .active class when the page is first loaded? Current Code: https://codesandbox.io/s/recursing-lake-oetxj?file=/src/App.js Tried setting the first activeObject

Advertisement