UNPKG

@react-three/xr

Version:

VR/AR for react-three-fiber

28 lines (27 loc) 1.21 kB
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; import { useXRSessionModeSupported } from '../index.js'; /** * Guard that only **shows** its children by toggling their visibility based on whether the user's device supports a session mode. * * @param props * #### `children?` - `ReactNode` The ReactNode elements to conditionally show. * #### `mode` - `XRSessionMode` The session mode used to determine if the children will be shown. */ export function ShowIfSessionModeSupported({ children, mode }) { const supported = useXRSessionModeSupported(mode); return _jsx("group", { visible: supported, children: children }); } /** * Guard that only **renders** its children to the scene based on whether the user's device supports a session mode. * * @param props * #### `children?` - `ReactNode` The ReactNode elements to conditionally render. * #### `mode` - `XRSessionMode` The session mode used to determine if the children will be rendered. */ export function IfSessionModeSupported({ children, mode }) { const supported = useXRSessionModeSupported(mode); if (!supported) { return null; } return _jsx(_Fragment, { children: children }); }