I would like to redirect to a component in case the data of the success has a certain value.
When ajax returns the data, depending on the value of the data redirected to the Contents class that I previously imported.
I've been looking for information about the push method
My error is: Error: Invariant failed: You should not use <Redirect> outside a <Router>
 import React, { Component } from 'react';
    import { Modal,Button } from 'react-bootstrap';
    import $ from 'jquery'; 
    import {  Redirect } from 'react-router';
    import Contents from './Contents';
    class Login extends Component {
        constructor(props, context) {
            super(props, context);
            this.handleShow = this.handleShow.bind(this);
            this.handleClose = this.handleClose.bind(this);
            this.handleloginClick = this.handleloginClick.bind(this);
            this.handleUsernameChange = this.handleUsernameChange.bind(this);
            this.handlePasswordChange = this.handlePasswordChange.bind(this);
            this.state = {
              show: true,
              username: "",
              password: "",
            };
          }
          handleloginClick(event) {
          var parametros = {
            username: this.state.username,
            password: this.state.password
          }
          const { history } = this.props;
          $.ajax({
            data: parametros,
            url: "https://privada.mgsehijos.es/react/login.php",
            type: "POST",
            success: function (data) {
               }
          });   
      }
      handleUsernameChange(event) {
            this.setState({username: event.target.value});
        }
        handlePasswordChange(event) {
          this.setState({password: event.target.value});
      }
        handleClose() {
        this.setState({ show: false });
      }
      handleShow() {
        this.setState({ show: true });
      }
         render() {
    If(Condicion){     
         return (<Redirect to={'./Contents'} />);
       }
 return (
          //Here my modal.
     );
              }
          }
          export default Login;
 
    