Skip to content

Instantly share code, notes, and snippets.

@barraponto
Last active September 29, 2020 17:30
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save barraponto/c370c17b2499c36a625fe1326c57ab21 to your computer and use it in GitHub Desktop.
Save barraponto/c370c17b2499c36a625fe1326c57ab21 to your computer and use it in GitHub Desktop.
import React from 'react';
const handleChange = (handler) => ({target: {files}}) =>
handler(files.length ? {file: files[0], name: files[0].name} : {});
export default ({
input: {onChange, onBlur, value: omitValue, ...inputProps},
meta: omitMeta,
...props
}) => (
<input type="file"
onChange={handleChange(onChange)} onBlur={handleChange(onBlur)}
{...inputProps} {...props} />
);
@raman-radius
Copy link

great! thanks. 👍

Copy link

ghost commented Sep 25, 2018

Thank you, been searching all day for this

@Millsky
Copy link

Millsky commented Apr 8, 2019

This is the only solution I've found to work so far, thanks!

@Mike1stver
Copy link

very usefull!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment