REACT ROUTER DOM FORMULAIRE DE deux pages
handleSubmit = (event) => {
event.preventDefault();
this.props.history.replace({
pathname: "/result",
state: {
value:
"Your saving range is: $" +
Math.floor(1.69 * this.state.square * (10 / 100)) +
"- $" +
Math.floor(1.69 * this.state.square * (30 / 100))
}
});
};
class Result extends Component {
render() {
return (
<div className="result">
<h2>You could save between</h2>
<h1>{this.props.location.state.value}</h1> // <-- route state
<NavLink to="/">Use Calculator Again</NavLink>
</div>
);
}
}
DevPedrada