Skip to content
This repository has been archived by the owner on Jun 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #146 from MiscLG/master
Browse files Browse the repository at this point in the history
adds React Hooks usage example
  • Loading branch information
JakeHartnell authored Mar 5, 2020
2 parents a5be2f6 + 8ec2df1 commit c5bf1bb
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm install --save react-images-upload
```

## Usage

### Using Classes
```javascript
import React from "react";
import ImageUploader from "react-images-upload";
Expand Down Expand Up @@ -41,7 +41,30 @@ class App extends React.Component {
}
}
```
### Using Hooks
```javascript
import React, { useState } from "react";
import ImageUploader from "react-images-upload";

const App = props => {
const [pictures, setPictures] = useState([]);

const onDrop = picture => {
setPictures([...pictures, picture]);
};
return (
<ImageUploader
{...props}
withIcon={true}
onChange={onDrop}
imgExtension={[".jpg", ".gif", ".png", ".gif"]}
maxFileSize={5242880}
/>
);
};

export default App;
```
### Available Options

| parameter | type | default | description |
Expand Down

0 comments on commit c5bf1bb

Please sign in to comment.