0

I am working on react app, where I was able to redirect from one to another page with just

 this.props.history.push('/home')

But now with new version I am not able to find any direct way to redirect in between pages,

This is not working for me.

import React, { Component } from 'react';
import { useNavigate } from 'react-router-dom';

class index extends Component {

    routeChange=()=> {
        let navigate = useNavigate();
        navigate('/home');
    }

    
    render() {
        return (
            <div>
                This is login page <br/><br/>
                <button onClick={this.routeChange}>Home</button>
            </div>

        );
    }
}

export default index;

Please guide with any solution.

Kirankumar Dafda
  • 2,354
  • 5
  • 29
  • 56

0 Answers0