Skip to content

Commit 0733d33

Browse files
committed
Address feedback about types
1 parent 3435740 commit 0733d33

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

packages/react-core/src/components/FileUpload/FileUpload.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import Dropzone, { DropzoneProps } from 'react-dropzone';
2+
import Dropzone, { DropzoneProps, DropFileEventHandler } from 'react-dropzone';
33
import { Omit } from '../../helpers';
44
import { FileUploadField, FileUploadFieldProps } from './FileUploadField';
55
import { readFile, fileReaderType } from '../../helpers/fileUtils';
@@ -75,22 +75,20 @@ export interface FileUploadProps
7575
dropzoneProps?: DropzoneProps;
7676
}
7777

78-
// TODO handle an optional message for errors without using FieldGroup
79-
8078
export const FileUpload: React.FunctionComponent<FileUploadProps> = ({
8179
id,
8280
type,
8381
value = type === fileReaderType.text || type === fileReaderType.dataURL ? '' : null,
8482
filename = '',
8583
children = null,
86-
onChange = (): any => undefined,
87-
onReadStarted = (): any => undefined,
88-
onReadFinished = (): any => undefined,
89-
onReadFailed = (): any => undefined,
84+
onChange = () => {},
85+
onReadStarted = () => {},
86+
onReadFinished = () => {},
87+
onReadFailed = () => {},
9088
dropzoneProps = {},
9189
...props
9290
}: FileUploadProps) => {
93-
const onDropAccepted = async (acceptedFiles: File[], event: React.DragEvent<HTMLElement>) => {
91+
const onDropAccepted: DropFileEventHandler = async (acceptedFiles: File[], event: React.DragEvent<HTMLElement>) => {
9492
if (acceptedFiles.length > 0) {
9593
const fileHandle = acceptedFiles[0];
9694
if (type === fileReaderType.text || type === fileReaderType.dataURL) {
@@ -110,7 +108,7 @@ export const FileUpload: React.FunctionComponent<FileUploadProps> = ({
110108
dropzoneProps.onDropAccepted && dropzoneProps.onDropAccepted(acceptedFiles, event);
111109
};
112110

113-
const onDropRejected = (rejectedFiles: File[], event: React.DragEvent<HTMLElement>) => {
111+
const onDropRejected: DropFileEventHandler = (rejectedFiles: File[], event: React.DragEvent<HTMLElement>) => {
114112
if (rejectedFiles.length > 0) {
115113
onChange('', rejectedFiles[0].name, event);
116114
}

packages/react-core/src/components/FileUpload/FileUploadField.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
7878
/** Flag to show if a file is being dragged over the field */
7979
isDragActive?: boolean;
8080
/** A reference object to attach to the FileUploadField container element. */
81-
containerRef?: React.Ref<any>;
81+
containerRef?: React.Ref<HTMLDivElement>;
8282
}
8383

8484
export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
8585
id,
8686
type,
8787
value = '',
8888
filename = '',
89-
onChange = (): any => undefined,
90-
onBrowseButtonClick = (): any => undefined,
91-
onClearButtonClick = (): any => undefined,
89+
onChange = () => {},
90+
onBrowseButtonClick = () => {},
91+
onClearButtonClick = () => {},
9292
className = '',
9393
isDisabled = false,
9494
isReadOnly = false,
@@ -104,7 +104,7 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
104104
browseButtonText = 'Browse...',
105105
clearButtonText = 'Clear',
106106
isClearButtonDisabled = !filename && !value,
107-
containerRef = null as React.Ref<any>,
107+
containerRef = null as React.Ref<HTMLDivElement>,
108108
children = null,
109109
showPreview = false,
110110
...props

0 commit comments

Comments
 (0)