markdalgleish/redial

React-redux's connect with provideHooks provides "Failed propType: Required prop `property` was not specified in"

DWboutin opened this issue · 4 comments

Hi,

I can't provide hooks to a connected component properly.

App.propTypes = {
  children: React.PropTypes.object.isRequired,
  loggedIn: React.PropTypes.bool.isRequired,
  user: React.PropTypes.object.isRequired,
  dispatch: React.PropTypes.func.isRequired,
  history: React.PropTypes.object.isRequired,
  location: React.PropTypes.object.isRequired,
  application: React.PropTypes.object.isRequired,
};

const hooks = {
  fetch: ({ dispatch }) => {
    request
      .get(config.API_URL + '/offers/findAllOfferCategories')
      .end((err, res) => {
        dispatch(receiveCategories(res.body));
      });
  },
  defer: () => console.log('defer'),
  done: () => console.log('done'),
};

export default provideHooks(hooks)(connect(state => ({ loggedIn: state.login.loggedIn, user: state.login.user, application: state.application }))(App));

It give me this
capture d ecran 2016-02-05 a 10 49 19

All the props are in the state correctly. If i remove provideHooksit works well.

How can i do this?

Thank you

I just remove the .isRequired, but i don't know why i have to remove them...

Not sure if it's related, but your fetch hook needs to return a promise.

Do you have a working example somewhere I can have a look at? I can't debug this when it's just a snippet, so I'm closing this issue for now, but please re-open once you've done this.

Alternatively, a failing test case would be even better.