0.2.4 • Published 4 years ago

lazy-upload v0.2.4

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

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

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

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

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.0.0

4 years ago