상세 컨텐츠

본문 제목

파일 접근 - react-native-document-picker

react-native-tool

by RNDK 2023. 6. 28. 11:15

본문

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;
}
}
};

관련글 더보기

댓글 영역