title: How to call useSelector inside callback
body: <p>This is a follow up question to this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/59456816/how-to-call-usedispatch-in-a-callback">How to call useDispatch in a callback</a></p>
  
  <p>I got a React component which needs to receive information from redux in its props. The information is taken using a custom hook.</p>
  
  <p>This is the custom hook:</p>
  
  <pre><code>  export function useGetData(selectorFunc)
    {
      return type =&gt;
      {
        if(!type)
        {
          throw new Error("got a wrong type");
        }
        let myData = selectorFunc(state =&gt; 
        {
          let res = JSON.parse(sessionStorage.getItem(type));
          if(!res )
          {
            res = state.myReducer.myMap.get(type);
          }
          return res;
        });
        return myData;
      }
    }
  </code></pre>
  
  <p>Based on the answer for the linked question, I tried doing something like this:</p>
  
  <pre><code>function Compo(props)
  {
     const getDataFunc = useGetData(useSelector);
     return &lt;MyComponent dataNeeded = { getDataFunc(NeededType).dataNeeded } /&gt;
  }
  </code></pre>
  
  <p>but I get an error because an hook can not be called inside a callback.</p>
  
  <p>How can I fix this issue?</p>