0.2.4 • Published 4 years ago
lazy-upload v0.2.4
Installing
Using npm:
npm i --save lazy-upload
Using yarn:
yarn add --dev lazy-upload
Usage
Here are examples of how you can use lazy-upload
.
useLazyUpload
File upload hook
Examples
Basic
const UPLOAD_FILES_URL = '';
export const UploadField = () => {
const {
acceptedFiles,
attributes,
rejectedFiles,
reset,
upload,
uploadedFiles,
} = useLazyUpload({});
console.log({ rejectedFiles, uploadedFiles });
return (
<form
onSubmit={e => {
upload({
config: {
url: UPLOAD_FILES_URL,
method: 'POST',
},
fileList: acceptedFiles,
});
e.preventDefault();
}}
>
<label htmlFor="file-upload">Choose files:</label>
<input {...attributes} id="file-upload" name="file-upload" />
<button onClick={reset}>Reset</button>
<button type="submit">Submit</button>
</form>
);
};
Running the tests
Tests are written with jest
Unit tests
Using jest:
yarn run test
Deployment
Deployment is done with Travis.
Built With
- TSDX - TSDX
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Arnaud Zheng - Initial work - arnaud-zg
See also the list of contributors who participated in this project.
Show your support
Give a ⭐️ if this project helped you!
License
This project is licensed under the MIT License - see the LICENSE file for details