title: How to use Reselect selectors inside a Redux reducer
body: <p>My app already has a large collection of selectors used by the various container objects. These are great for accessing different parts of the state and make refactoring the state much easier.</p>
  
  <p>Now I want to use my selectors inside some of my reducer functions. The problem is that inside the reducer, the <code>state</code> parameter refers to a specific slice of the state, whereas the selector functions expect to be called with the state root object.</p>
  
  <p><strong>Contrived Example:</strong></p>
  
  <pre><code>/* Selectors */
  const getTodos = state =&gt; state.todos;
  
  const getUncompletedTodos = createSelector(
      [ getTodos ],
      todos =&gt; todos.filter(t =&gt; !t.completed)
  );
  
  /* Reducer */
  const todosReducer = (state, action) =&gt; {
    switch (action.type) {
      case 'ADD_TODO':
        return [
          ...state,
          {
            id: action.id,
            text: action.text,
            completed: false
          }
        ];
      case 'REMOVE_COMPLETED_TODOS':
        return getUncompletedTodos(state); // &lt;-- this won't work
    }
  }
  </code></pre>