react on submit direct to new page code example
Example 1: redirect onclick react
import React from 'react';
import { useHistory } from "react-router-dom";
function Home() {
const history = useHistory();
const handleRoute = () =>{
history.push("/about");
}
return (
<Button
onClick={handleRoute}>
About
</Button>
);
}
export default Home;
Example 2: send props from one component to another on button click
<div>
<button>View Order</button>
<p><span>{this.props.orderno}</span>
<span>{this.props.title}</span></p>
<p>{this.props.entity} - {this.props.po}</p>
<p>Due {this.props.duedate}</p>
</div>