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

add react form #2125

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

add react form #2125

wants to merge 2 commits into from

Conversation

AnoriFrell
Copy link

Comment on lines 13 to 19
// const [count, setCount] = useState(0);

// const [title, setTitle] = useState('');
// const [description, setDescription] = useState('');
// const [imgUrl, setImgUrl] = useState('');
// const [imdbUrl, setImdbUrl] = useState('');
// const [imdbId, setImdbId] = useState('');

Choose a reason for hiding this comment

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

remove comments

// 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);

Choose a reason for hiding this comment

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

you should have this state to increase counter on submit

// const [imdbUrl, setImdbUrl] = useState('');
// const [imdbId, setImdbId] = useState('');

const [movieData, setMovieData] = useState({

Choose a reason for hiding this comment

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

move default state object to a variable

} = movieData;

const reset = () => {
setMovieData((prevData) => ({

Choose a reason for hiding this comment

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

just pass default state object

Comment on lines 80 to 85
onChange={(newValue) => setMovieData(
{
...movieData,
title: newValue,
},
)}

Choose a reason for hiding this comment

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

move this onClick handler to an own function so you'll reuse it for cases below as well

Copy link

@Viktor-Kost Viktor-Kost left a comment

Choose a reason for hiding this comment

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

cool!

Comment on lines +10 to +16
const defaultMovieData = {
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.

move outside the component

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.

2 participants