-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0b5013
commit 29fb4f3
Showing
13 changed files
with
129 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { AnswersHeadless } from '@yext/answers-headless'; | ||
import { SearchHeadless } from '@yext/search-headless'; | ||
import { createContext } from 'react'; | ||
|
||
// The default is empty because we don't know the user's config yet | ||
export const SearchHeadlessContext = createContext<AnswersHeadless>({} as AnswersHeadless); | ||
export const SearchHeadlessContext = createContext<SearchHeadless>({} as SearchHeadless); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { AnswersHeadless } from '@yext/answers-headless'; | ||
import { SearchHeadless } from '@yext/search-headless'; | ||
import { useContext } from 'react'; | ||
import { SearchHeadlessContext } from './SearchHeadlessContext'; | ||
|
||
export type SearchActions = AnswersHeadless; | ||
export type SearchActions = SearchHeadless; | ||
|
||
export function useSearchActions(): SearchActions { | ||
const answersHeadless = useContext(SearchHeadlessContext); | ||
if (answersHeadless.state === undefined) { | ||
const searchHeadless = useContext(SearchHeadlessContext); | ||
if (searchHeadless.state === undefined) { | ||
throw new Error('Attempted to call useSearchActions() outside of SearchHeadlessProvider.' | ||
+ ' Please ensure that \'useSearchActions()\' is called within an SearchHeadlessProvider component.'); | ||
} | ||
return answersHeadless; | ||
return searchHeadless; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.