chore: moved to a new branch to save space
This commit is contained in:
19
directory/src/state/background.js
Normal file
19
directory/src/state/background.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { useCallback } from 'react';
|
||||
import { atom, useAtom } from 'jotai';
|
||||
|
||||
const backgroundsAtom = atom([]);
|
||||
|
||||
export function useBackgrounds() {
|
||||
const [backgrounds, setBackgrounds] = useAtom(backgroundsAtom);
|
||||
|
||||
const fetchBackgrounds = useCallback(async () => {
|
||||
const res = await fetch('/_assets/backgrounds.json')
|
||||
const data = await res.json()
|
||||
setBackgrounds(data)
|
||||
}, [setBackgrounds])
|
||||
|
||||
return {
|
||||
backgrounds,
|
||||
fetchBackgrounds
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user