0

I am trying to redirect when a button is clicked but is not working. I did a console log on the handleClick event and it did log in the console. Here is the code and I am not sure where did I go wrong? Thanks in advance.

import React from 'react'
import { Redirect } from "react-router-dom";

const Home = () => {

    function handleClick() {
       return <Redirect to='/aboutus' />
    }

    return (
        <div>
            <button type="button" onClick={handleClick}>
                Go About Us
            </button>
        </div>
    )
}

export default Home
Nat
  • 679
  • 1
  • 9
  • 24

1 Answers1

1

Handle click return a component, there is no actual action. Use Link instead.

Achal Jain
  • 309
  • 1
  • 7