wip(shared): Removed useApp hook in favor of contexts
This removes the useApp hook from all org pages in favor of various context. This means there is no longer global state that gets passed around, instead each component that requires access to something shared (like account, or navigation) can just use the context instead. This is a first step, as a lot of shared components stil rely on app not to mention the dev and lab sites.
This commit is contained in:
parent
e717457454
commit
e47c18177b
84 changed files with 1457 additions and 1296 deletions
24
sites/shared/context/loading-context.mjs
Normal file
24
sites/shared/context/loading-context.mjs
Normal file
|
@ -0,0 +1,24 @@
|
|||
import React, { useState } from 'react'
|
||||
|
||||
export const LoadingContext = React.createContext(false)
|
||||
|
||||
export const LoadingContextProvider = ({ children }) => {
|
||||
function stopLoading() {
|
||||
__setLoading({ ...__loading, loading: false })
|
||||
}
|
||||
function startLoading() {
|
||||
__setLoading({ ...__loading, loading: true })
|
||||
}
|
||||
function setLoading(loading) {
|
||||
__setLoading({ ...__loading, loading })
|
||||
}
|
||||
|
||||
const [__loading, __setLoading] = useState({
|
||||
setLoading,
|
||||
startLoading,
|
||||
stopLoading,
|
||||
loading: false,
|
||||
})
|
||||
|
||||
return <LoadingContext.Provider value={__loading}>{children}</LoadingContext.Provider>
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue