i am trying to make button and after make button i want to make ad event lisner on by click on this button it will show some message but i am able to create only button but not able to add event listener on it.please help me on it.
function Button()
{
return (
<button id='btn'>Masai</button>
);
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(Button());
function showAlert()
{
return(
<p>You clicked Masai!</p>
);
}
const msg=ReactDOM.createRoot(document.querySelector('#message'));
document.querySelector('button').addEventListener('click',()=>{
msg.render(showAlert());
})