I am having a songKey array as a STATE. Its data populates from API. I am rendering JSX using this array data. I like to add useRef in order to refer elements from the JSX. Is it possible to add useRef hooks via code automatically ? or shall I use document.getElementById() function to refer elements ?
const [songKey, songKeyController] = useState([]);
...
...
...
...
...
const renderLyrics = () => {
let lyrics = [];
if (songKey) {
lyrics = songKey.map((key) => (
<div key={key} className={`lyrics_container ${key}`}>
<div className="lyrics_data tamil-font">
{props.currentSong.Data[key]}
</div>
</div>
));
}
return lyrics;
};