Skip to content

Commit

Permalink
optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Lvyshnevska committed May 9, 2024
1 parent d975006 commit 64c374c
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const UserInfo = (props) => {
}));
};

const errorsInNameSurname = formStateErr['name']['message'].length > 1 || formStateErr['surname']['message'].length > 1;
const errorsInNameSurname = formStateErr['name']['message']?.length > 1 || formStateErr['surname']['message']?.length > 1;

const checkRequiredFields = () => {
let isValid = true;
Expand All @@ -100,10 +100,10 @@ const UserInfo = (props) => {
}
setFormStateErr({ ...formStateErr, ...newFormState });

if (updateUser.name.length < 2 || updateUser.surname.length < 2) {
if (updateUser.name?.length < 2 || updateUser.surname?.length < 2) {
isValid = false;
}
if (updateProfile.person_position.length !== 0 && updateProfile.person_position.length < 2) {
if (updateProfile.person_position?.length !== 0 && updateProfile.person_position?.length < 2) {
isValid = false;
}

Expand Down

0 comments on commit 64c374c

Please sign in to comment.