cleanup(phone/photos): Added type safety to photo state

This commit is contained in:
Taso committed 2021-04-01 13:35:43 -04:00
1 parent d363866a34
commit 8b746c8185
2 files changed
+5 -9

No files matched your search

+3 -2
View File
@@ -1,8 +1,9 @@
import { atom } from 'recoil'; import { atom } from 'recoil';
import { IPhoto } from '../../../../../typings/photo';
export const photoState = { export const photoState = {
photos: atom({ photos: atom<IPhoto[]>({
key: 'galleryPhotos', key: 'galleryPhotos',
default: null, default: [],
}), }),
}; };
+2 -7
View File
@@ -1,11 +1,6 @@
import { useRecoilValue } from 'recoil'; import { useRecoilValue } from 'recoil';
import { photoState } from './state'; import { photoState } from './state';
export interface ICameraPhoto { export const usePhotos = () => {
id: string; return useRecoilValue(photoState.photos);
image: string;
}
export const usePhotos = (): ICameraPhoto[] | null => {
return useRecoilValue<ICameraPhoto[] | null>(photoState.photos);
}; };