Skip to content
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 #2720

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

solution #2720

wants to merge 1 commit into from

Conversation

Blervin1
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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! 🎉 There are a few minor improvements you could consider, such as renaming the movies state for clarity and ensuring TextField handles onBlur validation. Also, you can optimize by removing the unnecessary spread operator when initializing the movies state. Keep up the good work and happy coding! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨


export const App = () => {
const [movies, setMovies] = useState<Movie[]>([...moviesFromServer]);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are using the spread operator to create a copy of moviesFromServer when initializing the movies state. According to the checklist, if you are using a non-mutating array method, you don't need to create a copy of the array. Consider removing the spread operator: useState<Movie[]>(moviesFromServer);.

type InputTypes = 'title' | 'description' | 'imgUrl' | 'imdbUrl' | 'imdbId';

export const NewMovie: FC<Props> = ({ onAdd }) => {
const [count, setCount] = useState(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The count state is used to reset the form by changing the key, which is a good approach to ensure the form is reinitialized. Ensure that the TextField component handles the onBlur event to validate inputs as per the task description.

Comment on lines +13 to +19
const [movies, setMovies] = useState({
title: '',
description: '',
imgUrl: '',
imdbUrl: '',
imdbId: '',
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming the movies state to something more descriptive like movieDetails to avoid confusion, as it represents a single movie's details rather than multiple movies.


export const NewMovie: FC<Props> = ({ onAdd }) => {
const [count, setCount] = useState(0);
const [movies, setMovies] = useState({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const [movies, setMovies] = useState({
const [movie, setMovie] = useState({

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants