<Route
exact
path="/calendar"
component={() => <Calendar name={register.name} />}
/>
submit = () => {
this.props.setName(this.state.name);
window.location = "/calendar";
};
<Route exact path='/' component={()=> <Register setName={setName}
name={register.name} />} />
const mapStateToProps = store => {
return {
register: store.register
}
}
const mapDispatchToProps = dispatch => {
return {
setName: name => dispatch(setName(name))
}
}
class Register extends React.Component {
state = {
name: ""
}
registerName = (e) => {
this.setState( {name: e.target.value} )
console.log(this.state.name);
}
submit = () => {
this.props.setCourt(this.state.name);
console.log(this.props.name) //ничего не выводит :(
}
render() {
return (
<div className="form-group">
<input className="form-control input-field"
onChange={this.registerName}
name="name"
type="text"
input={this.state.name}
/>
<button onClick={this.submit}>Submit</button>
</div>
)
}
}