title: reactjs - redux: how to access dispatch from selectors
body: <p>I have a situation like below:</p>
  
  <pre><code>state = {
       items: [.....list of items]
       filteredcount: count of filtered items done by selector
  }
  </code></pre>
  
  <p>I have a component with the following code to pass state properties.</p>
  
  <pre><code>const mapStateToProps = (state,ownProps) =&gt; {
      return {
          items: getItems(state.items,ownProps.condition),
          filteredcount: state.filteredcount
      }
  </code></pre>
  
  <p>Inside the getItems selector i want to dispatch an action to update the filteredcount.</p>
  
  <pre><code>const getItems = (results,condition){
      filteredresults = ...filter results here based on condition
      dispatch(updatenumber(filteredresults.length))
      return filteredresults
  }
  </code></pre>
  
  <p>where updatenumber is an action creator to update the state.filteredcount</p>
  
  <p>How to do this</p>