mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
Moved code into src folder. Added build for component library.
This commit is contained in:
parent
7a7233ead4
commit
ede658771e
490 changed files with 749 additions and 442 deletions
27
src/components/hooks/useConfig.js
Normal file
27
src/components/hooks/useConfig.js
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import { useEffect } from 'react';
|
||||
import useStore, { setConfig } from 'store/app';
|
||||
import useApi from 'components/hooks/useApi';
|
||||
|
||||
let loading = false;
|
||||
|
||||
export function useConfig() {
|
||||
const { config } = useStore();
|
||||
const { get } = useApi();
|
||||
|
||||
async function loadConfig() {
|
||||
const data = await get('/config');
|
||||
loading = false;
|
||||
setConfig(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!config && !loading) {
|
||||
loading = true;
|
||||
loadConfig();
|
||||
}
|
||||
}, []);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
export default useConfig;
|
||||
Loading…
Add table
Add a link
Reference in a new issue