File tree Expand file tree Collapse file tree 3 files changed +8
-8
lines changed
example/examples/src/routes/ImagePicker
packages/react-native-image-picker/src/ImagePicker Expand file tree Collapse file tree 3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ export default function MenuDropdownView(props: ImagePickerProps) {
1818 < Body >
1919 < Card title = "基础实例" >
2020 < ImagePicker
21- upload = { ( file : File [ ] ) => {
21+ upload = { async ( file : File [ ] ) => {
2222 let imageList : string [ ] = [ ] ;
23- file . forEach ( file => imageList . push ( file . uri ) ) ;
23+ await file . forEach ( file => imageList . push ( file . uri ) ) ;
2424 return imageList ;
2525 } }
2626 selectionLimit = { 2 }
@@ -44,9 +44,9 @@ export default function MenuDropdownView(props: ImagePickerProps) {
4444 < ImagePicker
4545 value = { [ 'https://wx3.sinaimg.cn/mw690/4718260ely1gt2cg7t5udj23dw1wkhdu.jpg' ] }
4646 maxCount = { 2 }
47- upload = { ( file : File [ ] ) => {
47+ upload = { async ( file : File [ ] ) => {
4848 let imageList : string [ ] = [ ] ;
49- file . forEach ( file => imageList . push ( file . uri ) ) ;
49+ await file . forEach ( file => imageList . push ( file . uri ) ) ;
5050 return imageList ;
5151 } }
5252 />
@@ -56,9 +56,9 @@ export default function MenuDropdownView(props: ImagePickerProps) {
5656 </ Card >
5757 < Card title = "上传前置处理" >
5858 < ImagePicker
59- upload = { ( file : File [ ] ) => {
59+ upload = { async ( file : File [ ] ) => {
6060 let imageList : string [ ] = [ ] ;
61- file . forEach ( file => imageList . push ( file . uri ) ) ;
61+ await file . forEach ( file => imageList . push ( file . uri ) ) ;
6262 return imageList ;
6363 } }
6464 beforeUpload = { ( file : File [ ] ) => {
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ export declare type ImagePickerProps = PropsWithChildren<{
2222 /** 上传文件之前的钩子,参数为上传的文件,若返回 false 则停止上传,同时可以在里面执行一些上传提示操作 */
2323 beforeUpload ?: ( file : File [ ] ) => boolean | ( ( file : File ) => Promise < boolean > ) ;
2424 /** 上传 */
25- upload ?: ( file : File [ ] ) => string [ ] ;
25+ upload ?: ( file : File [ ] ) => Promise < string [ ] > ;
2626 /** 上传完成 */
2727 uploadFinish ?: ( result ?: string [ ] | undefined ) => void ;
2828 /** 取消上传事件回调 */
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ export default function useImagePicker({
140140 }
141141 }
142142 setLoading ( true ) ;
143- const result = upload ?.( imageFiles ) ;
143+ const result = await upload ?.( imageFiles ) ;
144144 setLoading ( false ) ;
145145 uploadFinish ?.( result ) ;
146146 setLaunchVisibleFalse ( ) ;
You can’t perform that action at this time.
0 commit comments