Skip to content

Commit

Permalink
Convert accept type to the new one (#432)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox authored Sep 29, 2024
1 parent 2d18030 commit b4c3ffe
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Components/UploadImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,20 @@ class UploadImage extends Component<UploadImageProps, UploadImageState> {
render(): JSX.Element {
const { disabled, icon, removeIconFunc, error, crop, onChange } = this.props;
const maxSize = this.props.maxSize || 10 * 1024;
const accept = this.props.accept || { 'image/*': [] };
let accept = this.props.accept || { 'image/*': [] };
const { uploadFile, anchorEl, cropHandler } = this.state;

// covert '"image/png"' to { 'image/*': [] }
if (typeof accept === 'string') {
accept = { [accept]: [] };
} else if (Array.isArray(accept)) {
const result: Record<string, string[]> = {};
accept.forEach(item => {
result[item] = [];
});
accept = result;
}

return (
<Dropzone
disabled={!!disabled || cropHandler}
Expand Down

0 comments on commit b4c3ffe

Please sign in to comment.