title: Uncaught TypeError: Cannot read properties of undefined (reading 'undefined')
body: <p>I'm trying to change the state created with the useState hook when clicked. But I do not understand this mistake.
  Uncaught TypeError: Cannot read properties of undefined (reading 'undefined'). I do not understand why this happens after setState (state.activeQuestion + 1)</p>
  <pre class="lang-js prettyprint-override"><code>import React, {useState} from 'react'
  import classes from './Quiz.module.css'
  import ActiveQuiz from '../../components/ActiveQuiz/ActiveQuiz'
  
  export default function Quiz () {
  
      const [state, setState] = useState(
   {  activeQuestion: 0,     
      quiz: [
             {
                 question: 'Якого коліру небо',
                 rightAnswerId: 2,
                 id: 1,
                 answers: [
                     {text: 'чорний', id: 1},
                     {text: 'синій', id: 2},
                     {text: 'червоний', id: 3},
                     {text: 'зелений', id: 4}
                 ]  
             },
             {
              question: 'Якому році 2 світова',
              rightAnswerId: 3,
              id: 2,
              answers: [
                  {text: '1954', id: 1},
                  {text: '1948', id: 2},
                  {text: '1949', id: 3},
                  {text: '1918', id: 4}
              ]  
          }
         ],}
      )
  
      const onAnswerClickHandler = answerId =&gt; {
          console.log('Answer Id: ', answerId);
          setState(state.activeQuestion + 1)
      }
  
      return(
          &lt;div className={classes.Quiz}&gt;
              &lt;div className={classes.QuizWraper}&gt;
                  &lt;h1&gt; Дайте відповідь на всі Питання &lt;/h1&gt;
                  &lt;ActiveQuiz 
                      answers={state.quiz[state.activeQuestion].answers}
                      question={state.quiz[state.activeQuestion].question}
                      onAnswerClick={onAnswerClickHandler}
                      quizLength={state.quiz.length}
                      answerNumber={state.activeQuestion + 1}                   
                  /&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      )
      
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/kBxQY.png" rel="nofollow noreferrer">enter image description here</a></p>