diff --git a/src/uploader.js b/src/uploader.js index a32cd68..49bead5 100644 --- a/src/uploader.js +++ b/src/uploader.js @@ -6,7 +6,7 @@ import React, { } from 'react' import uploadcare from 'uploadcare-widget' -import { defaultPreviewUrlCallback } from './default-preview-url-callback' +import {defaultPreviewUrlCallback} from './default-preview-url-callback' import { useCommitedCallback, useCustomTabs, @@ -19,7 +19,8 @@ const useWidget = ( { id, name, - value, + value, // @deprecated + defaultValue, onFileSelect, onChange, onDialogOpen, @@ -167,11 +168,11 @@ const useWidget = ( }, [widgetOptions]) useEffect(() => { - if (cachedValueRef.current !== value) { - widget.current.value(value) + if (cachedValueRef.current !== defaultValue) { + widget.current.value(defaultValue) } - cachedValueRef.current = value - }, [value]) + cachedValueRef.current = defaultValue + }, []) useEffect(() => { if (uploadcare && tabsCss && typeof tabsCss === 'string') { @@ -195,7 +196,7 @@ const useWidget = ( ) return useCallback( - () => , + () => , [id, name] ) } @@ -203,7 +204,7 @@ const useWidget = ( const Uploader = (props) => { const Input = useWidget(props, uploadcare) - return + return } export default Uploader