Skip to content

Commit bcb7d50

Browse files
committed
Revert "Remount dropzone when options change"
This reverts commit 5d5d4aa.
1 parent 054bb07 commit bcb7d50

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/UploadDropzone.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Uploader, UploaderResult, UploaderOptions } from "uploader";
2-
import React, { useLayoutEffect, useState } from "react";
2+
import React, { useLayoutEffect } from "react";
33
import { useElementRef } from "react-uploader/Utils";
44

55
interface Props {
@@ -11,7 +11,7 @@ interface Props {
1111
width?: string;
1212
}
1313

14-
const UploadDropzoneInner = ({ uploader, options, onComplete, onUpdate, width, height }: Props): JSX.Element => {
14+
export const UploadDropzone = ({ uploader, options, onComplete, onUpdate, width, height }: Props): JSX.Element => {
1515
const [element, elementRef] = useElementRef();
1616

1717
useLayoutEffect(() => {
@@ -43,11 +43,3 @@ const UploadDropzoneInner = ({ uploader, options, onComplete, onUpdate, width, h
4343
/>
4444
);
4545
};
46-
47-
// We use 'JSON.stringify(props.options)' to force a reinitialization when options like colour and tags change.
48-
// Unfortunately this won't trigger a re-render in the event of a callback changing.
49-
// JSON.stringify will simply elide non-serializable fields like functions.
50-
export const UploadDropzone = (props: Props): JSX.Element => {
51-
const [id] = useState(Math.random().toString());
52-
return <UploadDropzoneInner {...props} key={`${id}-${JSON.stringify(props.options)}`} />;
53-
};

0 commit comments

Comments
 (0)