Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onClick fullscreen in React without wrapper or provider

Is there a way to enter fullscreen mode from any component in React without using providers or wrapper div?

I know that fullscreen mode can be achieved by using packages like fscreen or react-full-screen, but I'd like to omit that.

If wrapper or provider is obligatory, what's the most efficient way to enter fullscreen? I have a lot of components and different views and I want to have a button that onClick enters fullscreen of the whole page, regardless to where that button is inside DOM.

like image 681
cikcirikcik Avatar asked Oct 25 '25 10:10

cikcirikcik


1 Answers

In order to enter Full screen mode, you can run this on click:
Element.requestFullscreen()

And if you want to exit it you can call this method:
document.exitFullscreen()

like image 105
Mahir Molai Avatar answered Oct 27 '25 23:10

Mahir Molai