mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-27 17:19:27 +01:00
11 lines
314 B
TypeScript
11 lines
314 B
TypeScript
import { atomWithStorage } from 'jotai/utils';
|
|
import { getItem, setItem } from './asyncstorage';
|
|
|
|
export default <T>(key: string, defaultValue: T) => {
|
|
return atomWithStorage<T>(key, defaultValue, {
|
|
getItem: async () => await getItem(key) || defaultValue,
|
|
setItem: setItem,
|
|
delayInit: true,
|
|
});
|
|
}
|