Getters in Redux's actions - React Native
<p>I would like to have functions that can get the current state to do some logic with it, without having to pass the current state via parameters to the function.</p>

<p>Here is my example.</p>

<p>In my action file, I have: </p>

<pre><code>export const addToSearchHistory = (newSearch) =&gt; ({type: ADD_TO_SEARCH_HISTORY, newSearch})
export const addToCardHistory = (newCard) =&gt; ({type: ADD_TO_CARD_HISTORY, newCard})
</code></pre>

<p>And for example I would like to have a "getter" function that tells me if the "Search history" has hit 10 items. So what I did is:</p>

<pre><code>export const searchHasMaxHistory = () =&gt; (dispatch, getState) =&gt; {
  var state = getState()
      search = state.search

  return search.history == 10 ? true : false
}
</code></pre>

<p>And I bind this function with the other "real" actions with bindActionCreators:</p>

<pre><code>const mapDispatchToProps = (dispatch) =&gt; {
  return bindActionCreators({
    addToSearchHistory,
    addToCardHistory,

    searchHasMaxHistory
  }, dispatch)
} 
</code></pre>

<p>So I'll be accessible as any normal actions. It works well and does exactly what I want.</p>

<p>But the real question is, is it anti-pattern to bind it like an action but it doesn't return an action? May I run into issues or whatsoever by doing that? And is there a "right" solution to do that?</p>