mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-05-10 07:11:48 +00:00
cleanup
This commit is contained in:
parent
5686019587
commit
42579ce297
2 changed files with 13 additions and 10 deletions
|
|
@ -3,17 +3,13 @@
|
|||
import { createContext } from 'react';
|
||||
|
||||
export type FullscreenContextValue = readonly [
|
||||
boolean,
|
||||
() => Promise<void> | void,
|
||||
() => void,
|
||||
() => void,
|
||||
fullscreen: boolean,
|
||||
requestFullscreen: () => Promise<void> | void,
|
||||
exitFullscreen: () => void,
|
||||
toggleFullscreen: () => void,
|
||||
];
|
||||
|
||||
const noop = () => undefined;
|
||||
|
||||
const defaultValue: FullscreenContextValue = [false, noop, noop, noop];
|
||||
|
||||
const FullscreenContext = createContext<FullscreenContextValue>(defaultValue);
|
||||
const FullscreenContext = createContext<FullscreenContextValue | null>(null);
|
||||
|
||||
FullscreenContext.displayName = 'FullscreenContext';
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@
|
|||
import { useContext } from 'react';
|
||||
import FullscreenContext from './FullscreenContext';
|
||||
|
||||
const useFullscreen = () => useContext(FullscreenContext);
|
||||
const useFullscreen = () => {
|
||||
const value = useContext(FullscreenContext);
|
||||
if (value === null) {
|
||||
throw new Error('useFullscreen must be used inside FullscreenProvider');
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
export default useFullscreen;
|
||||
|
|
|
|||
Loading…
Reference in a new issue