import React from 'react' import { connect } from 'react-redux' import { addProduct } from '../actions/products' class MyForm extends React.Component { constructor(props) { super(props); this.state = {name: ''}; this.handleChange = this.handleChange.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } handleChange(evt) { this.setState({ name: evt.target.value }); } handleSubmit(evt) { console.log(`Votre nom est ${this.state.name}`); evt.preventDefault(); } componentDidMount() { this.props.dispatch(addProduct('pomme', 10)); } render() { return (
); } } export default connect()(MyForm)