feat(terminal): terminal wrapper and context
This commit is contained in:
15
src/context/TerminalContext.tsx
Normal file
15
src/context/TerminalContext.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
const TerminalContext = createContext<{ cols: number; height: number } | null>(
|
||||
null,
|
||||
);
|
||||
|
||||
export const TerminalContextProvider = TerminalContext.Provider;
|
||||
|
||||
export const useTerminal = () => {
|
||||
const context = useContext(TerminalContext);
|
||||
if (!context)
|
||||
throw new Error("useTerminal must be used inside a Terminal component");
|
||||
|
||||
return context;
|
||||
};
|
||||
Reference in New Issue
Block a user