Uri Klar
Uri Klar

Reputation: 3988

reselect using useSelector react-redux hook - state is not defined

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?

Upvotes: 2

Views: 4133

Answers (1)

Dennis Vash
Dennis Vash

Reputation: 53884

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

Upvotes: 3

Related Questions