Skip to content

Commit

Permalink
fix counter
Browse files Browse the repository at this point in the history
  • Loading branch information
dubyuliia committed Sep 30, 2023
1 parent 0632dce commit f830508
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/NewMovie/NewMovie.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Props = {
export const NewMovie: React .FC<Props> = ({ 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('');
Expand Down Expand Up @@ -41,6 +41,8 @@ export const NewMovie: React .FC<Props> = ({ onAdd }) => {
setImdbId('');
setImdbUrl('');
setImgUrl('');

setCount(number => number + 1);
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextField/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const TextField: React.FC<Props> = ({

// 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 (
<div className="field">
Expand Down

0 comments on commit f830508

Please sign in to comment.