import { Context, createContext, ReactNode, useContext } from 'react'; const defaultDeviceType = 'desktop'; type DeviceType = 'desktop' | 'mobile'; const DeviceTypeContext: Context = createContext(defaultDeviceType); type Props = { children: ReactNode; /** * The device type as determined by logic within your app. */ deviceType: DeviceType; }; /** * [DeviceTypeProvider](https://gestalt.pinterest.systems/web/utilities/devicetypeprovider) is an optional [React Context provider](https://reactjs.org/docs/context.html#contextprovider) to enable device-specific UI for Gestalt components that support it. */ export default function DeviceTypeProvider({ children, deviceType }: Props) { return {children}; } export function useDeviceType(): DeviceType { return useContext(DeviceTypeContext) ?? defaultDeviceType; }