-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OS-7719: Add RoutePathContext to access current route path in components
- Loading branch information
Showing
9 changed files
with
40 additions
and
15 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
5 changes: 1 addition & 4 deletions
5
ngui/ui/src/contexts/CommunityDocsContext/CommunityDocsContextProvider.tsx
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,3 @@ | ||
import { createContext } from "react"; | ||
|
||
export default createContext(""); |
13 changes: 13 additions & 0 deletions
13
ngui/ui/src/contexts/RoutePathContext/RoutePathContextProvider.tsx
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,13 @@ | ||
import { ReactNode } from "react"; | ||
import CurrentPathTemplateContext from "./RoutePathContext"; | ||
|
||
type RoutePathContextProviderProps = { | ||
children: ReactNode; | ||
path: string; | ||
}; | ||
|
||
const RoutePathContextProvider = ({ children, path }: RoutePathContextProviderProps) => ( | ||
<CurrentPathTemplateContext.Provider value={path}>{children}</CurrentPathTemplateContext.Provider> | ||
); | ||
|
||
export default RoutePathContextProvider; |
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,4 @@ | ||
import RoutePathContext from "./RoutePathContext"; | ||
import ChartsTooltipContextProvider from "./RoutePathContextProvider"; | ||
|
||
export { RoutePathContext, ChartsTooltipContextProvider }; |
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,8 @@ | ||
import { useContext } from "react"; | ||
import { RoutePathContext } from "contexts/RoutePathContext"; | ||
|
||
export const useRoutePath = () => { | ||
const path = useContext(RoutePathContext); | ||
|
||
return path; | ||
}; |
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