'Button to be clicked and routed to another page in React

 <button component={Link} to={"/create"}>
      <EditIcon></EditIcon>
 </button>

This is my code to make an icon a clickable button that routes to the page "create." The button is not performing any function. Can anyone help me out?



Solution 1:[1]

 <Link to={"/create"}
      <EditIcon />
 </Link >

and dont forget to import it from react-router-dom

import {Link} from "react-router-dom"

Solution 2:[2]

import { useHistory } from "react-router-dom";
const Button = ()=>{
let history = useHistory();
return(<>
<EditIcon onClick={()=>history.push("/create");}/>
</>

)}
export default Button;

here u can learn about react router from this link

https://v5.reactrouter.com/web/api/Hooks

Solution 3:[3]

`import {useNavigate} from 'react-router-dom

const navigate = useNaviagte()

<button onClick={()=>navigate("/create")}> `

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Houssem Salem
Solution 2 raas
Solution 3 codeVibek