-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react_movies-list-add-form #1873
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only spaces is not valid inputs, add url validation
https://github.com/mate-academy/react_movies-list-add-form/assets/61904995/0c168339-dc89-4038-81a6-40a15fa1ac2b
src/components/NewMovie/NewMovie.tsx
Outdated
const [nameValue, setNameValue] = useState(''); | ||
const [descriptionValue, setDescriptionValue] = useState(''); | ||
const [img, setImg] = useState(''); | ||
const [imdbUrlValue, setImdbUrlValue] = useState(''); | ||
const [imdbIdValue, setImdbIdValue] = useState(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets combine it into one state intead of 5
const [movie, setMovie] = useState({
title: '',
description: '',
....
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/App.tsx
Outdated
|
||
export const App = () => { | ||
const [moviesServer, setMoviesServer] = useState<Movie[]>(moviesFromServer); | ||
const onAdd = (newmovie:Movie) => { | ||
setMoviesServer([...moviesServer, newmovie]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setMoviesServer([...moviesServer, newmovie]); | |
setMoviesServer((moviesServer) => [...moviesServer, newmovie]); |
Consider using a callback here to avoid bugs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
https://OlegRak86.github.io/react_movies-list-add-form/