Search code examples
reactjsobjectreturn

Return Object, Object


I have the following React code:

const ResultItem = ({ category, name }) =>

  <div className="projects animated fadeInUp">
       <a href ={"/projects " + {name}}> 
       <h1 style ={project_box_h1}> {name} </h1></a>
    <div className={`category--${category}`} />
  </div>;

In h1 variable {name} is working correctly and returns "Name".

But, in a href variable {name} returns something like this:

http://localhost:1234/projects%20[object%20Object]

How can I fix it?


Solution

  • <a href ={"/projects " + name}>
    

    or

    <a href ={`/projects ${name}`}>