learning-react icon indicating copy to clipboard operation
learning-react copied to clipboard

chapter 8: repository menu carousel

Open stardvst opened this issue 3 years ago • 0 comments

when the entered user has no public repos, the following error is printed:

Cannot read properties of undefined (reading 'name')

i fixed RepoMenu.js with the following code. if you know better way to destructure the array, please suggest.

  const [repo, previous, next] = useIterator({ items: repos });
  const name = repo?.name;

also notice, you need to pass useIterator({ items: repos }) instead of useIterator(repos) (useIterator receives a prop named items).

stardvst avatar Aug 06 '22 11:08 stardvst