首页 > 解决方案 > javascript template litreral in side a react link tag to={} attribute

问题描述

<Link to={'${oldUrl}/${id}'} >

Hi, I am using template literal in a react app link tag and it is showing below error message please tell if anyone knows how to add it correctly?

Unexpected template string expression no-template-curly-in-string

标签: javascripttemplate-literals

解决方案


将您的代码更改为此

<Link to={`${oldUrl}/${id}`} >

它应该清除错误


推荐阅读