diff options
| author | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-13 18:04:18 +1100 |
|---|---|---|
| committer | Nicolas James <Eele1Ephe7uZahRie@tutanota.com> | 2025-02-13 18:04:18 +1100 |
| commit | 93dfe2be64e8658839bcfe5356adf35f8cde7075 (patch) | |
| tree | c60b1e20d569b74dbde85123e1b2bf3590c66244 /src/web/contexts | |
initial commit
Diffstat (limited to 'src/web/contexts')
| -rw-r--r-- | src/web/contexts/StateContext.jsx | 17 | ||||
| -rw-r--r-- | src/web/contexts/UserContext.jsx | 16 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/web/contexts/StateContext.jsx b/src/web/contexts/StateContext.jsx new file mode 100644 index 0000000..91579a4 --- /dev/null +++ b/src/web/contexts/StateContext.jsx @@ -0,0 +1,17 @@ +import React, {createContext, useState} from "react"; + +// Our StateContext are some variables which we want shared between components. +const StateContext = createContext(null); +function StateContextProvider({children}) { + const state = useState({ + loginActive: false, + }); + + return ( + <StateContext.Provider value={state}> + {children} + </StateContext.Provider> + ); +} + +export {StateContext, StateContextProvider};
\ No newline at end of file diff --git a/src/web/contexts/UserContext.jsx b/src/web/contexts/UserContext.jsx new file mode 100644 index 0000000..82e4f05 --- /dev/null +++ b/src/web/contexts/UserContext.jsx @@ -0,0 +1,16 @@ +import React, {createContext, useState} from "react"; + +import {maybeGetUser} from "helpers/Auth.jsx"; + +const UserContext = createContext(null); +function UserContextProvider({children}) { + const state = useState(maybeGetUser()); + + return ( + <UserContext.Provider value={state}> + {children} + </UserContext.Provider> + ); +} + +export {UserContext, UserContextProvider};
\ No newline at end of file |
