generated from sweetmantech/DACIRKUS_PERFORMERS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from SweetmanTech/test
Test
- Loading branch information
Showing
6 changed files
with
74 additions
and
32 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 |
---|---|---|
|
@@ -2,5 +2,4 @@ import { ReactNode } from "react" | |
|
||
export interface ILayout { | ||
children: ReactNode | ||
entered?: boolean | ||
} |
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,30 @@ | ||
import { createContext, useContext, useMemo, useState } from "react" | ||
|
||
const PageLoadContext = createContext(null) | ||
|
||
const PageLoadProvider = ({ children }) => { | ||
const [entered, setEntered] = useState(false) | ||
|
||
const value = useMemo( | ||
() => ({ | ||
entered, | ||
setEntered | ||
}), | ||
[ | ||
entered, | ||
setEntered | ||
], | ||
) | ||
|
||
return <PageLoadContext.Provider value={value}>{children}</PageLoadContext.Provider> | ||
} | ||
|
||
export const usePageLoad = () => { | ||
const context = useContext(PageLoadContext) | ||
if (!context) { | ||
throw new Error("usePageLoad must be used within a PageLoadProvider") | ||
} | ||
return context | ||
} | ||
|
||
export default PageLoadProvider |