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

implented #918

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

Conversation

ZadorozhnyiYevhenii
Copy link

Copy link

@VitaliyBondarenko1982 VitaliyBondarenko1982 left a comment

Choose a reason for hiding this comment

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

Compare your implementation with working example
do not show right side bar when no selected any post
Screenshot from 2023-09-21 14-55-26

Copy link

@IvanFesenko IvanFesenko left a comment

Choose a reason for hiding this comment

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

Good job, lets improve your code a bit. Also ypu could check similar case on other places

Comment on lines 18 to 23
const [name, setName] = useState('');
const [isNameError, setIsNameError] = useState(false);
const [email, setEmail] = useState('');
const [isEmailError, setIsEmailError] = useState(false);
const [body, setBody] = useState('');
const [isBodyError, setIsBodyError] = useState(false);

Choose a reason for hiding this comment

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

My assumption it's better to have 2 states instead of 6. One for fields

const [form, setForm] = useState({
  name: '',
  ....
});

second for error message< by default it's empty string
const [errorMsg, setErrorMsg] = useState('');

Comment on lines 89 to 92
onChange={(e) => {
setName(e.target.value);
setIsNameError(false);
}}

Choose a reason for hiding this comment

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

Do not use anonymous function use separate handler
It will works for all fields

const onFieldChange = ({taget: {value, name}}) => {
  setForm(prevState => {...prevState, [name]: value })
} 

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.

4 participants