reduxjs / reselect

Selector library for Redux
MIT License
19.04k stars 670 forks source link

lastResult.deref is not a function (it is undefined) #669

Closed quocluongha closed 10 months ago

quocluongha commented 10 months ago

I updated to v5 and I encountered this error message when using createSelectorCreator with weakMapMemoize.

I returned a number in selectFormPosition and this error happened, but I tried to change the returned result into object then it is working fine.

The createDeepEqualSelector function:

export const createDeepEqualSelector = createSelectorCreator(weakMapMemoize, {
  resultEqualityCheck: isEqual, // lodash isEqual
});

The state:

const initialState = {
  formPosition: 0,
};

The selector functions:

export const selectWithdrawalState = (state: RootState) =>
  state.shopper.profile.withdrawal;

export const selectFormPosition = createDeepEqualSelector(
  selectWithdrawalState,
  state => state.formPosition,
  // state => ({ formPosition: state.formPosition }), <-- this is working fine

);

image

aryaemami59 commented 10 months ago

I will take a look at this as soon as I get a chance, in the meantime if you remove the resaultEqualityCheck, the error should go away.

quocluongha commented 10 months ago

Thank you @aryaemami59, that is my temporary solution up to now.

aryaemami59 commented 10 months ago

@quocluongha Just a quick question, are you using React Native or Expo?

quocluongha commented 10 months ago

@aryaemami59 I am using React Native 0.72.7

aryaemami59 commented 10 months ago

@quocluongha Thank you, I'll put up a PR with the fix soon.

EskiMojo14 commented 10 months ago

Fix released in v5.1.0