title: How to add fresh data to an existing data in React-query?
body: <p>I have a code which calls an API with a certain number of data and receives them. I wish for the 2nd call to add the newly retrieved data to be added to the already existing data using React-query library.</p>
  <p>My code so far is :</p>
  <pre><code>const fetchData = async ({queryKey : [key , pages]}) =&gt; {
    
    return (await fetch(`http://jservice.io/api/random?count=${pages}`)).json()
  }
  
  function App() {
    const [state, setState] = React.useState(10);
    const {isLoading, error, data , } = useInfiniteQuery(['general' , state], fetchData , {keepPreviousData : true} )
  
    
    setTimeout(() =&gt; {
      setState(20)
    }, 4444);
  
    console.log(data)
    return (
      &lt;div className=&quot;App&quot;&gt;
        h
      &lt;/div&gt;
    );
  }
  </code></pre>
  <p>I wish to hit the 4444 time line marker by adding the newly fetched data to the existing data solely by using React-query hooks.</p>
  <p>How can I achieve this?</p>