title: Insert an element to a list inside another on nested variables on state in react
body: <p>I have a json of this type:</p>
  
  <pre><code>object:{
  
     object2:[
      {
        test:[
         {
         }
        ],
        name:''
      }
     ]
  
  }
  </code></pre>
  
  <p>What I want to do is to set the state of a certain test element and what I did was this:</p>
  
  <pre><code>this.setState(prevState =&gt; ({
          object: {
              ...prevState.object,
              object2: {
                  ...prevState.object.object2[indexObject2],
                  test: [
                      ...newTest
                  ]
              }
          }
      }))
  </code></pre>
  
  <p>But when I do this the error this.state.object.object2.map is not a function occurs.
  Thanks!</p>