aboutsummaryrefslogtreecommitdiff
path: root/src/console/completion/provider.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/console/completion/provider.tsx')
-rw-r--r--src/console/completion/provider.tsx25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/console/completion/provider.tsx b/src/console/completion/provider.tsx
new file mode 100644
index 0000000..c0de250
--- /dev/null
+++ b/src/console/completion/provider.tsx
@@ -0,0 +1,25 @@
+import reducer, { defaultState } from "./reducer";
+import React from "react";
+import { CompletionDispatchContext, CompletionStateContext } from "./context";
+
+interface Props {
+ initialInputValue: string;
+}
+
+export const CompletionProvider: React.FC<Props> = ({
+ initialInputValue,
+ children,
+}) => {
+ const initialState = {
+ ...defaultState,
+ completionSource: initialInputValue,
+ };
+ const [state, dispatch] = React.useReducer(reducer, initialState);
+ return (
+ <CompletionStateContext.Provider value={state}>
+ <CompletionDispatchContext.Provider value={dispatch}>
+ {children}
+ </CompletionDispatchContext.Provider>
+ </CompletionStateContext.Provider>
+ );
+};