
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.
24 lines
618 B
JavaScript
24 lines
618 B
JavaScript
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>
|
|
}
|