title: updating array useState react hooks (Next.js)
body: <p>I am trying to update my 'state' array and insert items of type String into it with 'setState' but it doesn't works.<br>
  I know it's not work with push().<br>
  I also tried to update my 'state' array with the spread operator but it also doesn't work.<br>
  Here my code:</p>
  
  <pre><code>import React, { useState } from 'react';
  import _, { debounce } from 'lodash';
  
  
  export default function Search() {
  
    const [state, setState] = useState([])
  
    const handleChange = debounce(async (value) =&gt; {
      const url = `http://localhost:3100/`
      if (value == '') {
        return
      }
      let response = await fetch(url, {
        headers: {
          'Content-Type': 'application/json'
        },
        method: 'POST',
        body: JSON.stringify({ value })
      })
  
      let test = await response.json()
      console.log(test)
  
      setState(state.concat(test))
      // setState([...state, test]) it also doesn't work
      console.log(state)    
    }, 1000)
  
    return (
      &lt;&gt;
        &lt;div&gt;
          &lt;input onChange={e =&gt; handleChange(e.target.value)} /&gt;
        &lt;/div&gt;
      &lt;/&gt;
    )
  }
  </code></pre>
  
  <p>The 'state' array remains empty. I need to understand why please.</p>