skortchmark9 / reselect-tools

Debugging Tools for Reselect

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`ReselectTools.registerSelectors()` fails if the given object has a null value property

javierfernandes opened this issue · comments

Hi !

I was starting to use the tool, and followed the setup code like this

in my storeCreator.js (setups the store)

import * as selectors from 'selectors/selectors'

ReselectTools.getStateWith(() => store.getState())
ReselectTools.registerSelectors(selectors)

And I was getting this exception

image

My selectors file seems a regular file

export { selectedObject, selectedObjects } from './objects'
export { vmLoading, vmLoaded, tasksComply } from './project'

I started to inspect the "selectors" object (from import * as selectors) and noticed that it has a couple of extra fields set by babel or whatever the underlying impl of the es modules creates.
And seems like one of those fields was null and made the library break.

I solved it by filtering some properties like this

    const distilledSelectors = Object.keys(selectors).reduce((acc, k) => {
      const v = selectors[k]
      if (v) acc[k] = v
      return acc
    }, {})
    ReselectTools.registerSelectors(distilledSelectors)

But maybe it would be great if the library already fixes this by checking for "selector" to be truthy.

Thanks !

You're right, I think I anticipated something like this, but that check needs to be fixed.

Moving all extension issues into the main repo, per #24