Can't useRef to get reference to DOM element
ianldgs opened this issue · comments
Ian Luca commented
Example:
const myRef = useRef(null);
useEffect(() => {
myRef.current.requestFullscreen();
}, []);
html`<div ref=${myRef}></div>`;
Current behaviour:
Uncaught TypeError: Cannot read property 'requestFullscreen' of undefined
Expected behaviour:
Element enters fullscreen if the browser supports it, some other error otherwise.
Based on this answer I have found a way to make it work. Tested with virtual
components! (which seems to be the most difficult part, so normal component
should be fine).
Would you accept a PR to address this?