title: Reuse selectors inside reducer with redux toolkit
body: <p>Is there any way to reuse selectors created by <code>createSelector</code> inside of reducers?</p>
  <p>My use case is that I have a graphql mutation (<code>createAsyncThunk</code>) inside of a slice. The function returns only a referenced id, so I will have to filter the passed in state (which is not the root state, but already the slice of it) by the referenced id.</p>
  <p>I do have my selectors in place which do have that functionality already, but neither can I use <code>useAppSelector</code> nor can I call the selector since it expects the root state.</p>
  <pre><code>extraReducers: (builder) =&gt; {
    // This is from an asyncThunk
    builder.addCase(acknowledgeAllTenantViolations.pending, (state, action) =&gt; {
       // Action will pass me a referenced id, I now need to update all violations matching that id
  
  }
  </code></pre>
  <p>Those are typical selectors I would like to reuse</p>
  <pre><code>export const selectViolationsNotAcknowledged = createSelector(
      [selectAllViolations],
      (violations) =&gt; violations.filter((violation) =&gt; !violation.acknowledged)
  )
  
  export const selectViolationsByTenant = createSelector(
      [selectViolationsNotAcknowledged, (state: RootState, tenantId: string) =&gt; tenantId],
      (violations, tenantId) =&gt; violations.filter((violation) =&gt; violation.tenantId=== 
    tenantId)
  )
  </code></pre>
  <p>If that is not possible is there any way to be handling the <code>state.entities</code> better? They are key object pairs and not very accessible since you will need to use <code>Object.entries(state.entities)</code>. I found out that I can do something like</p>
  <pre><code>extraReducers: (builder) =&gt; {
    // This is from an asyncThunk
    builder.addCase(acknowledgeAllTenantViolations.pending, (state, action) =&gt; {
       
    const {selectAll} = deviceViolationEntityAdapter.getSelectors&lt;typeof state&gt;((state) =&gt; state)
  }
  </code></pre>
  <p>But then I end up at the place where I need to recreate those selectors or at least have them around twice.</p>