I don't write react, but based on my knownledge on Vue, I think you should do this with states instead of revising the DOM directly.
However, talking about the TS code provided above by @hritik-sharma
Let's update a bit:
// You can indicate type like this
const list = document.querySelectorAll<HTMLElement>('.m-list')
// Avoid using "any", especially when you actually know the type
function activeLink(item: HTMLElement) {
// Go through the list and remove the class
list.forEach((listItem) => listItem.classList.remove('active'))
// Add active class to the clicked item
item.classList.add('active')
}
// Apply the function to click event
// You actually do not need the parameter "(e: MouseEvent)" inside "addEventListener"
list.forEach((listItem) => listItem.addEventListener('click', () => activeLink(listItem)))