I have been using react js for the past couple of months and just got to know about the sweetalert bootstrap plugin for react. on update of a component successfully a dialog appears onscreen. upon clicking the "click here" button history.push is invoked and it should route to a different page but I have been getting error
history.push is not defined.
I have googled quite a few stuff and tried quite a few scenarios but haven't been successful in it.
code snippet:
class displayBlank extends Component {
render(){
<div id="displayDetails">
<DisplayDetails respData={this.state.respData} />
</div>
}
}
export default displayBlank;
class displayDetails{
handleUpdate()
{
// Body of HandleUpdate
swal({
title :"Customer Updated Successfully!",
icon : "success",
button: "Click Here!",
}).then((e) => { history.push('/blank');
});
}
render(){
<table>
<tr>
<td>
Table-Grid Contents
</td>
</tr>
</table>
<td>
<FormGroup controlId="formControlsDisabledButton" style={buttonalignment}>
<Button className="float-right" bsStyle="primary" type="submit" onClick={this.handleUpdate}>Save</Button>
{' '}
<Button className="float-right" bsStyle="primary" type="submit" disabled>Download</Button>
{' '}
</FormGroup>
</td>
}
}
this.props.history
. If not, you may need to make use of withRouter. It would help if you show your routing code. – Nicholas Tower Dec 10 '18 at 21:12