Renamed query hooks. Fixed conversion bugs.
This commit is contained in:
19
src/components/hooks/useConfig.ts
Normal file
19
src/components/hooks/useConfig.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useApp, setConfig } from '@/store/app';
|
||||
import { getConfig } from '@/app/actions/getConfig';
|
||||
|
||||
export function useConfig() {
|
||||
const { config } = useApp();
|
||||
|
||||
async function loadConfig() {
|
||||
setConfig(await getConfig());
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!config) {
|
||||
loadConfig();
|
||||
}
|
||||
}, []);
|
||||
|
||||
return config;
|
||||
}
|
||||
Reference in New Issue
Block a user