import React from 'react';
import DocumentPicker from 'react-native-document-picker';
/**
*
* @param setImgError image error - 이미지가 아닌경우
* @param setImg image - 이미지 데이터 array
* @description 모바일 파일 실행
*/
export const pickFile = async (
setImgError: React.Dispatch<any>,
setImg: React.Dispatch<any>,
) => {
setImgError(null);
try {
const res = await DocumentPicker.pickMultiple({
type: [DocumentPicker.types.allFiles],
});
setImg(res[0]);
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// 유저 캔슬 모션
} else {
throw err;
}
}
};
댓글 영역