chore: export

This commit is contained in:
lencx
2023-01-13 23:59:38 +08:00
parent 0eb6c559c6
commit a2fcfa3b89
6 changed files with 100 additions and 34 deletions

17
src/hooks/useJson.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
import { useState } from 'react';
import { readJSON } from '@/utils';
import useInit from '@/hooks/useInit';
export default function useJson<T>(file: string) {
const [json, setData] = useState<T>();
const refreshJson = async () => {
const data = await readJSON(file);
setData(data);
};
useInit(refreshJson);
return { json, refreshJson };
}