rematch: selector is not a function

Hello, there is no clear from the documentation how to use selectors.

...
import { init, dispatch } from '@rematch/core'
import { select } from '@rematch/select'

const taxonomy = {
  state: {
    ...
  },
  reducers: {
    ...
  },
  selectors: {
    getAllByProject: (state, projectId) => {
      ...
    }
  }
 }

const store = init({
  models: { taxonomy },
  plugins: [select]
})

const mapState = (state) => ({
  projects: select.getAllByProject(state, '1')
})

connect(mapState, mapDispatch)(TaxonomyTree)

I thought I’d followed the selectors API documentation. But I’m getting only __WEBPACK_IMPORTED_MODULE_7__rematch_select__.select.getAllByProject is not a function. Is it possible to extend documentation about more examples how to use selectors?

@rematch/core: 0.5.3
@rematch/select: 0.2.2

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

It looks like @rematch/core@1.0.0-beta.5 and @rematch/select@1.0.2 are available on npm right now (you need beta core to use the beta select plugin). You can install them like this: npm install --save @rematch/core@1.0.0-beta.5 @rematch/select@1.0.2.

@danawoodman getSelect is part of the new @rematch/select beta (which is on master). Here is the latest version which you’ll get from npm install.

I believe this is still an issue. I installed @rematch/select v0.3.0 and the following returns undefined:

import { getSelect } from '@rematch/select'

console.log(getSelect) // undefined

@eric-burel I fixed the problem by updating @rematch/core to 1.0.0-alpa.4. Apparently, the latest stable version of @rematch/select is not compatible with the current stable version of @rematch/core. Perhaps it should?

I think you’re not initializing the plugin correctly

import selectorsPlugin, {select} from '@rematch/select'

const store = ({
    plugins: [selectorsPlugin()],
})