Skip to content

Commit e946abe

Browse files
authored
Update readme (#5)
* Update readme * Update readme * Bump package * Update type * Update readme
1 parent 9e46e4e commit e946abe

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ yarn add react-native-use-file-upload
1414

1515
## Example App
1616

17-
There is an example app in this repo as shown in the above gif. It is located within `example` and there is a small node server script within `example/server` [here](example/server/server.ts). You can start the node server within `example` using `yarn server`. The upload route in the node server intentionally throttles the upload requests. You can read more about this in the FAQs below.
17+
There is an example app in this repo as shown in the above gif. It is located within `example` and there is a small node server script within `example/server` [here](example/server/server.ts). You can start the node server within `example` using `yarn server`. The upload route in the node server intentionally throttles requests to help simulate a real world scenario.
1818

1919
## Usage
2020

@@ -136,7 +136,7 @@ useFileUpload({ headers });
136136
// OnProgressData type
137137
{
138138
item: UploadItem; // or a type that inherits UploadItem
139-
event: ProgressEvent<EventTarget>;
139+
event: ProgressEvent;
140140
};
141141
// event is the XMLHttpRequest progress event object and it's shape is -
142142
{
@@ -204,9 +204,9 @@ useFileUpload({ headers });
204204

205205
### Do requests continue when the app is backgrounded?
206206

207-
Requests will time out if you background the app. This can be addressed by using [react-native-background-upload](https://github.com/Vydia/react-native-background-upload).
207+
Requests continue when the app is backgrounded on android but they do not on iOS. This can be addressed by using [react-native-background-upload](https://github.com/Vydia/react-native-background-upload).
208208

209-
The React Native team did a a heavy lift to polyfill and bridge `XMLHttpRequest` to the native side for us. [There is an open PR in React Native to allow network requests to run in the background for iOS](https://github.com/facebook/react-native/pull/31838). There are plans to have a similar PR for Android as well. `react-native-background-upload` is great but if backgrounding can be supported without any native dependencies it is a win for everyone.
209+
The React Native team did a heavy lift to polyfill and bridge `XMLHttpRequest` to the native side for us. [There is an open PR in React Native to allow network requests to run in the background for iOS](https://github.com/facebook/react-native/pull/31838). `react-native-background-upload` is great but if backgrounding can be supported without any external native dependencies it is a win for everyone.
210210

211211
### Why send 1 file at a time instead of multiple in a single request?
212212

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-use-file-upload",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "A hook for uploading files using multipart form data with React Native. Provides a simple way to track upload progress, abort an upload, and handle timeouts. Written in TypeScript and no dependencies required.",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",

src/hooks/useFileUpload.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function useFileUpload<T extends UploadItem = UploadItem>({
3333
requests.current[item.uri] = xhr;
3434

3535
if (xhr.upload) {
36-
xhr.upload.onprogress = (event: ProgressEvent<EventTarget>) => {
36+
xhr.upload.onprogress = (event: ProgressEvent) => {
3737
onProgress?.({ item, event });
3838
};
3939
}

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export type UploadItem = {
1111

1212
export type OnProgressData<T extends UploadItem = UploadItem> = {
1313
item: T;
14-
event: ProgressEvent<EventTarget>;
14+
event: ProgressEvent;
1515
};
1616

1717
export type OnDoneData<T extends UploadItem = UploadItem> = {

0 commit comments

Comments
 (0)