Files
video.js-mirror/apps/sandbox/app/shared/react/use-direction.ts

13 lines
456 B
TypeScript

import type { TextDirection } from '@app/constants';
import { getDirection, onDirectionChange } from '@app/shared/sandbox-listener';
import { useEffect, useState } from 'react';
/** The shell's pinned text direction, or `auto` to let the player follow its locale. */
export function useDirection(): TextDirection {
const [direction, setDirection] = useState(getDirection);
useEffect(() => onDirectionChange(setDirection), []);
return direction;
}