Search code examples
reactjsrouterlink-to

React: router link with param not working


enter image description here

My problem is passing ${file.id} to link, but when I navigate to that link, I only receive like this: enter image description here

the ${file.id} is not get correct value. But when I inspect the key of row, it can render correct.

enter image description here What are my mising?

Thanks


Solution

  • You are using the wrong quotes. String interpolation is not possible with single quotes or doublequotes. You have to use the backtick `

    So

    <Link to={'api/admin/blobManager/${file.id}'} />

    should instead be

    <Link to={`api/admin/blobManager/${file.id}`} />