How can we pass parameter with this.props.history.push(\'/page\')
in React-Router v4?
.then(response => {
var r = this;
if (re
To use React 16.8+(withHooks) you can use this way
import React from 'react';
import { useHistory } from 'react-router-dom';
export default function SomeFunctionalComponent() {
let history = useHistory(); // should be called inside react component
const handleClickButton = () => {
"funcionAPICALL"
.then(response => {
if (response.status >= 200 && response.status < 300) {
history.push('/template');
});
}
return ( Some component stuff
To make API POST request and redirect to "/template" click a button API CALL
)
}
Source here to read more https://reacttraining.com/react-router/web/example/auth-workflow