aboutsummaryrefslogtreecommitdiff
path: root/lib/context/isOpenState.js
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-09-26 23:35:35 +0700
committerFactiven <[email protected]>2023-09-26 23:35:35 +0700
commit20b8a7267827e3a07c1eef668c3b9c22fda43765 (patch)
tree2fec9006dfac5737d8b227bf5ccce73880800cc2 /lib/context/isOpenState.js
parentUpdate release.md (diff)
downloadmoopa-4.1.2.tar.xz
moopa-4.1.2.zip
Update v4.1.2v4.1.2
Diffstat (limited to 'lib/context/isOpenState.js')
-rw-r--r--lib/context/isOpenState.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/context/isOpenState.js b/lib/context/isOpenState.js
new file mode 100644
index 0000000..6aade61
--- /dev/null
+++ b/lib/context/isOpenState.js
@@ -0,0 +1,17 @@
+import React, { createContext, useContext, useState } from "react";
+
+const SearchContext = createContext();
+
+export const SearchProvider = ({ children }) => {
+ const [isOpen, setIsOpen] = useState(false);
+
+ return (
+ <SearchContext.Provider value={{ isOpen, setIsOpen }}>
+ {children}
+ </SearchContext.Provider>
+ );
+};
+
+export function useSearch() {
+ return useContext(SearchContext);
+}