From f506758bfecc180d7f1c9cb8046a4fd8db328a54 Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 15:07:25 +0300 Subject: [PATCH] change function position --- .../molecules/FormFields/FilesInput/index.tsx | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/molecules/FormFields/FilesInput/index.tsx b/src/components/molecules/FormFields/FilesInput/index.tsx index f779b76c5..e4ab3d84c 100644 --- a/src/components/molecules/FormFields/FilesInput/index.tsx +++ b/src/components/molecules/FormFields/FilesInput/index.tsx @@ -14,26 +14,6 @@ export default function FilesInput(props: InputProps): ReactElement { const [fileUrl, setFileUrl] = useState() const { config } = useOcean() - useEffect(() => { - loadFileInfo() - }, [fileUrl, config.providerUri]) - - async function handleButtonClick(e: React.SyntheticEvent, url: string) { - // hack so the onBlur-triggered validation does not show, - // like when this field is required - helpers.setTouched(false) - - // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() - - // In the case when the user re-add the same URL after it was removed (by accident or intentionally) - if (fileUrl === url) { - loadFileInfo() - } - - setFileUrl(url) - } - function loadFileInfo() { const source = axios.CancelToken.source() @@ -61,6 +41,26 @@ export default function FilesInput(props: InputProps): ReactElement { } } + useEffect(() => { + loadFileInfo() + }, [fileUrl, config.providerUri]) + + async function handleButtonClick(e: React.SyntheticEvent, url: string) { + // hack so the onBlur-triggered validation does not show, + // like when this field is required + helpers.setTouched(false) + + // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' + e.preventDefault() + + // In the case when the user re-add the same URL after it was removed (by accident or intentionally) + if (fileUrl === url) { + loadFileInfo() + } + + setFileUrl(url) + } + return ( <> {field?.value && field.value[0] && typeof field.value === 'object' ? (