diff options
| author | Factiven <[email protected]> | 2023-09-26 23:35:35 +0700 |
|---|---|---|
| committer | Factiven <[email protected]> | 2023-09-26 23:35:35 +0700 |
| commit | 20b8a7267827e3a07c1eef668c3b9c22fda43765 (patch) | |
| tree | 2fec9006dfac5737d8b227bf5ccce73880800cc2 /lib/context/isOpenState.js | |
| parent | Update release.md (diff) | |
| download | moopa-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.js | 17 |
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); +} |