I have this code in my React component:
const audio = useRef(new Audio(song));
console.log(audio.current) this is the result:
<audio id="beep" preload="auto" src="/static/media/ding-sound.ab26721d1e2926a00214.mp3">
The result is a HTML audio tag with id, preload and src attributes.
Here comes my problem.
In my render method I have:
However, the audio element doesn’t render and the console shows this error "Objects are not valid as a React child (found: [object HTMLAudioElement]).
Any ideas how to render audio.current?
I tried also with audio.current.outerHTML, but then it renders as a string.