Home > Blockchain >  how can i pass the const data to the navlink component url
how can i pass the const data to the navlink component url

Time:12-01

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

export const LinkMenu = () => {

    const masterControl = ["excursion", "agencie","guide","driver","vehicle"] 
  
  return (
    <div className="text-center text-light">
      <h6>Master Control</h6> 
       { masterControl.map((data) =>{ 
        let res = <div><NavLink style={{textDecoration: 'none', color:"rgb(214, 62, 24)" }} to="/data">{data}</NavLink><br></br></div>
        return res
      })}
      </div> 
  )}

I just need what is returned by the data constants to be able to pass it as the path

CodePudding user response:

use curly brackets

to={`/${data}`}

CodePudding user response:

<NavLink style={{textDecoration: 'none', color:"rgb(214, 62, 24)" }} to={`/${data}`}>{data}</NavLink>
  • Related