Skip to content

Instantly share code, notes, and snippets.

@toots
Created April 3, 2022 19:01
Show Gist options
  • Save toots/453ff3375f7cec582069bc3c0bac798c to your computer and use it in GitHub Desktop.
Save toots/453ff3375f7cec582069bc3c0bac798c to your computer and use it in GitHub Desktop.
interface SearchContextType {
show: boolean
setShow: (_: boolean) => void
query: string
setQuery: (_: string) => void
}
const SearchContext = createContext<SearchContextType>({} as SearchContextType)
export const SearchProvider = ({ children }: { children: React.ReactNode }) => {
const [show, setShow] = useState(false)
const [query, setQueryState] = useState('')
const router = useRouter()
return (
<SearchContext.Provider value={{ show, setShow, query, setQuery }}>
{children}
</SearchContext.Provider>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment