react-boilerplate: Promise Error when creating route to a container

I’m new to react and I decide to use this boilerplate for my first project. I don’t know if this is a bug or if I need to link some things manually, but when I create a container and a route to this new container with the generator, I get an error when I try to access this container.

The error is the following:

es6.promise.js:119 Unhandled promise rejection ReferenceError: injectAsyncReducer is not defined

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 38 (18 by maintainers)

Most upvoted comments

  1. pulled repo
  2. npm run setup
  3. npm run clean
  4. npm run generate container (let’s call it “Surveys”)
  5. npm run generate route (“/surveys”)
  6. go to /surveys
  7. see blank page with console error “ReferenceError: injectReducer is not defined”
  8. go to app/routes.js
  9. uncomment “import { getAsyncInjectors } from ‘utils/asyncInjectors’;”
  10. uncomment “const { injectReducer, injectSagas } = getAsyncInjectors(store);”
  11. add store to createRoutes “export default function createRoutes(store) {”

@ralomucho What do you mean by changing the default selector? (I’m getting the same error as @jamesmbowler)

Edit: Nevermind, I figured it out. A simple way to remove the error would be to do this:

const selectMyContainer = () => createSelector(
  selectMyContainerDomain(),
  (substate) => {
    return {}; //This is where you need to add the state for the container
  }
);

Double edit: Perhaps a good default for the template would be something like this instead? This way the errors won’t show up when nothing has changed.

const selectMyContainer = () => createSelector(
  selectMyContainerDomain(),
  (substate) => substate.toJS()
);

Yeah, do those two things and then the store variable is passed into the createRoutes function. I.e. change it to this:

export default function createRoutes(store) {

Thanks for the solution @ralomucho. I submitted the PR as others may already have problem with this: #352