React-redux's connect with provideHooks provides "Failed propType: Required prop `property` was not specified in"
DWboutin opened this issue · 4 comments
DWboutin commented
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));
All the props are in the state correctly. If i remove provideHooks
it works well.
How can i do this?
Thank you
DWboutin commented
I just remove the .isRequired, but i don't know why i have to remove them...
markdalgleish commented
Not sure if it's related, but your fetch hook needs to return a promise.
markdalgleish commented
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
Alternatively, a failing test case would be even better.