hookshot/web/context.ts
Will Hunt 6d3800a018
Convert bridgeAPI usages to preact context. (#871)
* Fix widget client only talking to localhost

* Improve error text around widget communication.

* changelog

* Remove unused.

* Simplify code by using a context for bridge API.
2024-01-16 09:44:51 +00:00

16 lines
337 B
TypeScript

import { createContext } from "preact";
import type { BridgeAPI } from "./BridgeAPI";
interface IBridgeContext {
bridgeApi: BridgeAPI;
}
const fakeBridgeContext = {
get bridgeApi(): BridgeAPI {
throw Error('No context provided');
}
}
export const BridgeContext = createContext<IBridgeContext>(fakeBridgeContext);