Skip to content

Commit

Permalink
feat: add ability to pass custom "id"
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Jan 1, 2019
1 parent 32bbf98 commit e5814e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Files.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export type FilesRules = {
};

export type Props = FilesRules & {
children: RenderPropParams => React.Node
children: RenderPropParams => React.Node,
id?: string
};

class Files extends React.Component<Props> {
Expand Down Expand Up @@ -191,7 +192,7 @@ class Files extends React.Component<Props> {
};

render() {
const { multiple, accept } = this.props;
const { multiple, accept, id } = this.props;
return (
<div>
{this.props.children({
Expand All @@ -204,7 +205,7 @@ class Files extends React.Component<Props> {
getLabelProps: (props: ?Object) => {
return {
...props,
htmlFor: this.id
htmlFor: id || this.id
};
},
getDropZoneProps: (props: ?Object) => {
Expand All @@ -225,7 +226,7 @@ class Files extends React.Component<Props> {
}
})}
<input
id={this.id}
id={id || this.id}
ref={ref => {
if (ref) {
this.input = ref;
Expand Down
1 change: 1 addition & 0 deletions stories/ImageGallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ImageGallery extends React.Component<Props, State> {
<example>
<div id="wrapper">
<Files
id={"image-gallery"}
multiple
convertToBase64
accept={["image/jpg", "image/jpeg", "image/png"]}
Expand Down

0 comments on commit e5814e3

Please sign in to comment.