-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
solution for movies form add #2770
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.
Great job on implementing the core functionality of managing and adding movies! 🎉 While there are some minor improvements suggested, such as renaming variables for clarity and updating the onChange
handlers for better readability, these do not impact the overall functionality of your code. Keep up the good work and consider these suggestions for future enhancements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
src/App.tsx
Outdated
|
||
export const App = () => { | ||
const [movie, setMovie] = useState<Movie[]>(moviesFromServer); |
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.
Consider renaming the state variable movie
to movies
to better reflect that it holds an array of movies. This will improve code readability and maintain consistency with the plural form used in moviesFromServer
.
src/components/NewMovie/NewMovie.tsx
Outdated
value="" | ||
onChange={() => {}} | ||
value={title} | ||
onChange={setTitle} |
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.
The onChange
handler should be a function that receives an event and updates the state. Consider changing onChange={setTitle}
to onChange={(e) => setTitle(e.target.value)}
to properly handle the input change event.
src/components/NewMovie/NewMovie.tsx
Outdated
name="description" | ||
label="Description" | ||
value={description} | ||
onChange={setDescription} |
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.
Similar to the previous comment, update onChange={setDescription}
to onChange={(e) => setDescription(e.target.value)}
to correctly handle the input change event.
src/components/NewMovie/NewMovie.tsx
Outdated
name="imgUrl" | ||
label="Image URL" | ||
value={imgUrl} | ||
onChange={setImgUrl} |
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.
Update onChange={setImgUrl}
to onChange={(e) => setImgUrl(e.target.value)}
to ensure the input change event is handled properly.
src/components/NewMovie/NewMovie.tsx
Outdated
name="imdbUrl" | ||
label="Imdb URL" | ||
value={imdbUrl} | ||
onChange={setImdbUrl} |
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.
Update onChange={setImdbUrl}
to onChange={(e) => setImdbUrl(e.target.value)}
to correctly handle the input change event.
src/components/NewMovie/NewMovie.tsx
Outdated
name="imdbId" | ||
label="Imdb ID" | ||
value={imdbId} | ||
onChange={setImdbId} |
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.
Update onChange={setImdbId}
to onChange={(e) => setImdbId(e.target.value)}
to ensure the input change event is handled properly.
src/components/NewMovie/NewMovie.tsx
Outdated
const [title, setTitle] = useState(''); | ||
const [description, setDescription] = useState(''); | ||
const [imgUrl, setImgUrl] = useState(''); | ||
const [imdbUrl, setImdbUrl] = useState(''); | ||
const [imdbId, setImdbId] = 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.
we can combine it in one useState
const [newMovie, setNewMovie] = useState({
title: '',
...
})
now we can also create only one handle function for all fields
const handleChange = (e: ...) => {
const {name, value} = e.target;
setMovie((prevMovie) => ({...prevMovie, [name]: value}))
}
don't forget to specify name attr to input in TextField
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.
amazing
DEMO LINK