refactor: reached same app state using vite
This commit is contained in:
16
src/context/TerminalContext.tsx
Normal file
16
src/context/TerminalContext.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
/* eslint-disable react-refresh/only-export-components */
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
const TerminalContext = createContext<
|
||||
{ cols: number; rows: number } | undefined
|
||||
>(undefined);
|
||||
|
||||
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