You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailchat/client/web/plugins/com.msgbyte.openapi/src/MainPanel/context.tsx

32 lines
743 B
TypeScript

import React, { useContext } from 'react';
import { OpenApp } from './types';
interface OpenAppInfoContextProps extends OpenApp {
refresh: () => Promise<void>;
}
const OpenAppInfoContext = React.createContext<OpenAppInfoContextProps>(null);
OpenAppInfoContext.displayName = 'OpenAppInfoContext';
export const OpenAppInfoProvider: React.FC<
React.PropsWithChildren<{
appInfo: OpenApp;
refresh: OpenAppInfoContextProps['refresh'];
}>
> = (props) => {
return (
<OpenAppInfoContext.Provider
value={{
...props.appInfo,
refresh: props.refresh,
}}
>
{props.children}
</OpenAppInfoContext.Provider>
);
};
export function useOpenAppInfo() {
return useContext(OpenAppInfoContext);
}