Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change inputProps override order #53

Merged
merged 2 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ Class added to the Files component when user is actively hovering over the dropz

---

`inputProps` - *Object*

Default: `{}`

Inject properties directly into the underlying HTML `file` input. Useful for setting `required` or overriding the `style` attributes.

---

## Examples

To run the examples locally, clone and install peer dependencies (React 16.8+)
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const Files = ({
maxFileSize = Infinity,
minFileSize = 0,
name = 'file',
onChange = files => console.log(files),
onChange = files => console.log(files), // eslint-disable-line no-console
onDragEnter,
onDragLeave,
onError = err => console.log(`error code ${err.code}: ${err.message}`),
onError = err => console.log(`error code ${err.code}: ${err.message}`), // eslint-disable-line no-console
style
}) => {
const idCounter = useRef(1)
Expand Down Expand Up @@ -161,13 +161,13 @@ const Files = ({
return (
<>
<input
accept={accepts ? accepts.join() : ''}
style={{ display: 'none' }}
{...inputProps}
ref={inputElement}
type="file"
accept={accepts ? accepts.join() : ''}
multiple={multiple}
name={name}
style={{ display: 'none' }}
onChange={handleDrop}
/>
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}
Expand Down