1
0
Fork 0

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:
Joost De Cock 2023-04-28 21:23:06 +02:00
parent e717457454
commit e47c18177b
84 changed files with 1457 additions and 1296 deletions

View 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>
}