With react html elements has also attributes onDrop, onDragOver, onDragEnter and onDragLeave.
So you can avoid the use of useRef and the useEffect to add / remove eventListener
the below code
(props: React.PropsWithChildren<FileListProps>) => (
can be written as follow
(props: FileListProps) => (
this will avoid the use of this line
App.displayName = 'App'
The below function
const mapFileListToArray = (files: FileList) => { const array = [] for (let i = 0; i < files.length; i++) { array.push(files.item(i)) } return array }
could be written as follow
const mapFileListToArray = (files: FileList) => Array.from(files)
My suggestion for The below code
{files.length === 0 ? ( <h3>No files to upload</h3> ) : ( <h3>Files to upload: {files.length}</h3> )}
Could be written as follow
<h3> {files?.length ? `Files to upload: ${files.length}` : "No files to upload" </h3>
Also i think the use of memo and useCallback are not necessary.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
With react html elements has also attributes onDrop, onDragOver, onDragEnter and onDragLeave.
So you can avoid the use of useRef and the useEffect to add / remove eventListener
the below code
can be written as follow
this will avoid the use of this line
The below function
could be written as follow
My suggestion for The below code
Could be written as follow
Also i think the use of memo and useCallback are not necessary.