У меня есть вопрос, есть ли возможность вызывать действия из функции или обработчика событий?Я использую React-Redux.
Пример:
export class Page extends React.Component {
onSomething() {
this.props.onAdd();
};
render() {
return (
<div>
<List
SomeMethod={this.onSomething};
/>
</div>
);
}
}
Page.propTypes = {
onAdd: PropTypes.func,
};
export function mapDispatchToProps(dispatch) {
return {
onAdd: evt => {
dispatch(fetchAdd());
},
};
}
const withConnect = connect(
mapStateToProps,
mapDispatchToProps,
);
const withReducer = injectReducer({ key: 'page', reducer });
const withSaga = injectSaga({ key: 'page', saga });
export default compose(
withReducer,
withSaga,
withConnect,
)(Page);
Я получаю сообщение об ошибке: Uncaught TypeError: Cannot read property 'onAdd' of undefined
Может кто-то знает, что я делаю плохо?