Skip to content

17.04.2019#13

Open
anton1evdokimov wants to merge 3 commits into
LeonEsquire:masterfrom
anton1evdokimov:master
Open

17.04.2019#13
anton1evdokimov wants to merge 3 commits into
LeonEsquire:masterfrom
anton1evdokimov:master

Conversation

@anton1evdokimov

Copy link
Copy Markdown

No description provided.

@anton1evdokimov

Copy link
Copy Markdown
Author

Lesson 8

Comment thread Lesson5/src/app/components/UsersList.js Outdated
<h1>Пользователи</h1>
{userL.map((user, index) => <User key={index} {...user} />)}
</div>
);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

return (
  <>
    {userL.length && (
      <div>
        <h1>Пользователи</h1>
        {userL.map((user, index) => (
          <User key={index} {...user} />
        ))}
      </div>
    )}
  </>
);

userL - хоть и пустой массив, но он все равно будет truthy (т.е. будет true)

Comment thread Lesson5/src/app/pages/User.js Outdated
};
}
const User = props => {
const [userS, setUserS] = useState({});

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
const [userS, setUserS] = useState({});
const [userS, setUserS] = useState(null);

чтобы код указанный ниже ( {userS && <UserProfile {...userS} />} ) работал корректно:)

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