benefits of pure component in react code example
Example 1: pure components
import { useHistory } from "react-router-dom";
function HomeButton() {
const history = useHistory();
function handleClick() {
history.push("/home");
}
return (
<button type="button" onClick={handleClick}>
Go home
</button>
);
}
Example 2: pure components
import { browserHistory } from 'react-router';
browserHistory.push('/some/path');