mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
cleanup(phone/photos): Added type safety to photo state
This commit is contained in:
1 parent
d363866a34
commit
8b746c8185
2 files changed
+5
-9
No files matched your search
@@ -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: [],
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -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);
|
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user