tylermcginnis/redux-course-2

selection answer 4

Pomar81 opened this issue · 2 comments

I've found that there is the problem in the Poll component. Problem is appeared when you select answer 4.

Code with problem:

  const vote = getVoteKeys().reduce((vote, key) => {
    if (vote !== null) {
      return vote[0]
    }

    return poll[key].includes(authedUser)
      ? key  //<- problem here!!!!!  
      : vote
  }, null)

I suggest solution:

  const vote = getVoteKeys().reduce((vote, key) => {
    if (vote !== null) {
      return vote
    }

    return poll[key].includes(authedUser)
      ? key[0]
      : vote
  }, null)

Thank you Pomar81! I had the same exact issue as you. Appreciate you doing the debugging for us.

I was just going to file this issue 😄