markdalgleish / redial

Universal data fetching and route lifecycle management for React etc.
1.1k stars 42 forks source link

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

Closed DWboutin closed 8 years ago

DWboutin commented 8 years ago

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

DWboutin commented 8 years ago

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

markdalgleish commented 8 years ago

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

markdalgleish commented 8 years ago

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.

markdalgleish commented 8 years ago

Alternatively, a failing test case would be even better.