I'm using ReactJs. When my web app loads, I want it to play a sound. But that's not possible, because apparently, the browser wants the user to interact with the DOM first before you can do that. Is what I'm trying to do even possible, and if yes, how?
This is the thing I've tried so far, it doesn't work
export default function App(props) {
const container = useRef();
useEffect(() => {
let click = new Event('click');
container.current.dispatchEvent(click);
}, []);
return (
<div ref={ container }></div>
);
}