title: React Hook "useState" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function
body: <p>React Hook is not working, giving error as attached screenshot:-
  <a href="https://i.stack.imgur.com/jTyLX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jTyLX.jpg" alt="enter image description here" /></a></p>
  <p>My Code:-</p>
  <pre><code>import React, { useState} from 'react';
  
  import WEBINAR_LIST from './webinar_data';
  
  const [ page, setPage ] = useState(0); //create page state
  
  const pageData = useMemo(() =&gt; {
  
       return WEBINAR_LIST.slice(page*5, (page*5)+5)
  },[page])
  
  const nextPage = () =&gt; setPage(prev =&gt; prev+1)
  const prevPage = () =&gt; setPage(prev =&gt; prev &gt; 0 ? prev-1 : prev) 
  </code></pre>
  <p>Thanks!</p>