diff --git a/src/components/NewMovie/NewMovie.tsx b/src/components/NewMovie/NewMovie.tsx index 7b942094b..9e1f97110 100644 --- a/src/components/NewMovie/NewMovie.tsx +++ b/src/components/NewMovie/NewMovie.tsx @@ -9,7 +9,7 @@ type Props = { export const NewMovie: React .FC = ({ onAdd }) => { // Increase the count after successful form submission // to reset touched status of all the `Field`s - const [count] = useState(0); + const [count, setCount] = useState(0); const [title, setTitle] = useState(''); const [description, setDescription] = useState(''); const [imdbId, setImdbId] = useState(''); @@ -41,6 +41,8 @@ export const NewMovie: React .FC = ({ onAdd }) => { setImdbId(''); setImdbUrl(''); setImgUrl(''); + + setCount(number => number + 1); }; return ( diff --git a/src/components/TextField/TextField.tsx b/src/components/TextField/TextField.tsx index 307b19865..6583e6803 100644 --- a/src/components/TextField/TextField.tsx +++ b/src/components/TextField/TextField.tsx @@ -29,7 +29,7 @@ export const TextField: React.FC = ({ // To show errors only if the field was touched (onBlur) const [touched, setTouched] = useState(false); - const hasError = touched && required && !value; + const hasError = touched && required && !value.trim(); return (