While learning about React-Redux I stumbled across the following code where I am not sure what's the difference between the following two lines and using mapDispatchToProps?
let { dispatch, actions } = this.props;
dispatch(actions.createTodo({ todo }));
Can someone please tell me the difference in using the above two lines and using mapDispatchToProps? Also can the above two lines be used in components, containers or only in components? Thanks
import React from 'react';
import ReactDOM from 'react-dom';
export default class TodoForm extends React.Component {
createTodo(e) {
e.preventDefault();
let input = ReactDOM.findDOMNode(this.input);
let todo = input.value;
// ????
let { dispatch, actions } = this.props;
dispatch(actions.createTodo({ todo }));
input.value = '';
}
render() {
return (
<div>
<Form horizontal onSubmit={::this.createTodo}>
</Form>
</div>
);
}
}