13 lines
416 B
TypeScript
13 lines
416 B
TypeScript
import { useContext } from "react";
|
|
import { DeviceProviderContext } from "./DeviceProvider";
|
|
import { DeviceEntry } from "../ProtocolProvider/protocol/packets/packet.device.list";
|
|
|
|
export function useDevices() : DeviceEntry[] {
|
|
const context = useContext(DeviceProviderContext);
|
|
|
|
if(!context) {
|
|
throw new Error("useDevices must be used within a DeviceProvider");
|
|
}
|
|
|
|
return context.devices;
|
|
} |