2

I'm having an issue integrating reselect when using react-redux's useSelector hook.

For some reason, the state in my selector is always undefined.
I reproduced it in this sandbox.

(Take a look at the Simple.js component). The state is fine in the useSelector hook but is then undefined when inside the selector. I added console logs that demonstrate the issue.

What am I doing wrong?

Dennis Vash
  • 50,196
  • 9
  • 100
  • 118
Uri Klar
  • 3,800
  • 3
  • 37
  • 75

1 Answers1

3

You didn't provide a result function:

const selector = createSelector(
  state => ({
    ...state.reducer
  }),
  state => state
);

According to the API docs:

createSelector(...inputSelectors | [inputSelectors], resultFunc)

Edit Q-59552085-ReselectExample

Dennis Vash
  • 50,196
  • 9
  • 100
  • 118