reselect icon indicating copy to clipboard operation
reselect copied to clipboard

createSelectorCreator Not Working

Open scefali opened this issue 9 years ago • 3 comments

I am trying to create a selector that uses a deep equality check. However, when I feed in a the lodash equality check, it doesn't seem to be working! I just copy and pasted the code you suggested:

import { createSelector, createSelectorCreator, defaultMemoize } from 'reselect'
import { isEqual } from 'lodash'

const createDeepEqualSelector = createSelectorCreator(
  defaultMemoize,
  isEqual
)

export const ccNumSelect = createDeepEqualSelector( state => {
    const rawCCNumber = payAddressSelect(state, 'rawCCNumber')
    if (rawCCNumber) {
        return rawCCNumber.replace(/[^\d]/g, '')
    }
    return ''
})

When my state updates, I don't see it going into my ccNumSelect method at all; it only happens upon initialization. I am using redux-form but I don't think that should matter. Any idea what's going on?

scefali avatar Mar 26 '17 01:03 scefali

@ellbee Well I tried reverting to version 2.5.4 and it's not working still. So I guess it's not the new version. Any idea what could be going on?

scefali avatar Mar 28 '17 00:03 scefali

Hey @Sangeli, if you can provide me with a working example I can run which demonstrates the problem I'll take a look for you.

ellbee avatar Mar 31 '17 08:03 ellbee

I think if you use multiple functions inside the createDeepEqualsSelector, it will work. It will deep compare the value returned from the first function(s). I'm still playing around with this myself, and was actually googling for the answer

danschumann avatar Jan 03 '18 03:01 danschumann