11 lines
323 B
TypeScript
11 lines
323 B
TypeScript
import { useContext } from "react";
|
|
import { DeviceProviderContext } from "./DeviceProvider";
|
|
|
|
export function useDeviceId(): string {
|
|
const context = useContext(DeviceProviderContext);
|
|
if(!context) {
|
|
throw new Error("useDeviceId must be used within a DeviceProvider");
|
|
}
|
|
|
|
return context.deviceId;
|
|
} |