diff --git a/src/pages/home/Profile.js b/src/pages/home/Profile.js index e7f76a7..73f4af3 100644 --- a/src/pages/home/Profile.js +++ b/src/pages/home/Profile.js @@ -85,7 +85,6 @@ const Profile = () => { const [file, setFile] = useState(null); const [error, setError] = useState(null); - const fileSelector = useRef(); const usernameRef = useRef(); const displayNameRef = useRef(); const currPassRef = useRef(); @@ -93,8 +92,8 @@ const Profile = () => { const newPassRepeatRef = useRef(); const submit = async ({ target: button }) => { - button.disabled = true; if (!file) return; + button.disabled = true; const body = new FormData(); body.set('file', file, file.name); @@ -102,7 +101,7 @@ const Profile = () => { const response = await post('/api/user/avatar', body, { headers: null }); if (!response.success) setError(response.message); - else fileSelector.current.value = null; + else setFile(null); button.disabled = false; }; @@ -146,7 +145,7 @@ const Profile = () => {

Change Profile Picture

- +