learning-react
learning-react copied to clipboard
chapter 8: repository menu carousel
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).