diff --git a/resources/scripts/components/server/files/NewDirectoryButton.tsx b/resources/scripts/components/server/files/NewDirectoryButton.tsx index c8e39b22f..987fe0dad 100644 --- a/resources/scripts/components/server/files/NewDirectoryButton.tsx +++ b/resources/scripts/components/server/files/NewDirectoryButton.tsx @@ -45,11 +45,11 @@ export default ({ className }: WithClassname) => { const directory = ServerContext.useStoreState(state => state.files.directory); useEffect(() => { - if (visible) { - return () => { - clearFlashes('files:directory-modal'); - }; - } + if (!visible) return; + + return () => { + clearFlashes('files:directory-modal'); + }; }, [ visible ]); const submit = ({ directoryName }: Values, { setSubmitting }: FormikHelpers) => {