github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/public/src/components/RedirectButton.tsx (about)

     1  import React from "react"
     2  import { useHistory } from "react-router"
     3  
     4  
     5  const RedirectButton = ({ to }: { to: string }): JSX.Element => {
     6      const history = useHistory()
     7  
     8      // The button is hidden if user is currently at the location the button redirects to
     9      const isHidden = history.location.pathname == to ? true : false
    10  
    11      return (
    12          <div className={"btn btn-dark redirectButton"} onClick={() => history.push(to)} hidden={isHidden}>
    13              <i className="fa fa-arrow-left" />
    14          </div>
    15      )
    16  }
    17  
    18  export default RedirectButton