-
-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix bug: text overlap in search result
- Loading branch information
1 parent
1cfc30f
commit 86f8d01
Showing
5 changed files
with
121 additions
and
35 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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React, { createContext, useContext, useState, ReactNode } from 'react' | ||
|
||
interface ResultsContextValue { | ||
results: number | ||
setResults: React.Dispatch<React.SetStateAction<number>> | ||
} | ||
|
||
const ResultsContext = createContext<ResultsContextValue | null>(null) | ||
|
||
export const ResultsProvider: React.FC<{ children: ReactNode }> = ({ | ||
children, | ||
}) => { | ||
const [results, setResults] = useState<number>(-1) | ||
|
||
return ( | ||
<ResultsContext.Provider value={{ results, setResults }}> | ||
{children} | ||
</ResultsContext.Provider> | ||
) | ||
} | ||
|
||
export const useResults = () => { | ||
const context = useContext(ResultsContext) | ||
if (!context) { | ||
throw new Error('useResults must be used within a ResultsProvider') | ||
} | ||
return context | ||
} |
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