最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - template string of es6 in attribute of react component - Stack Overflow

programmeradmin4浏览0评论

I can use a double and single quote to concatenate my dynamic variable but template string is cleaner. I got an unexpected token, any clue why?

...
return (<UserList id={subactions} key=`applications${query.status}` />)
...

I can use a double and single quote to concatenate my dynamic variable but template string is cleaner. I got an unexpected token, any clue why?

...
return (<UserList id={subactions} key=`applications${query.status}` />)
...
Share Improve this question edited Dec 28, 2024 at 1:18 Penny Liu 17.4k5 gold badges86 silver badges108 bronze badges asked Jun 8, 2017 at 4:57 Giala JeffersonGiala Jefferson 1,9298 gold badges22 silver badges30 bronze badges 3
  • Please add a tag for your environment/framework. – user663031 Commented Jun 8, 2017 at 5:02
  • would key={'applications'+query.status} work? – Jaromanda X Commented Jun 8, 2017 at 5:07
  • 5 would key={`applications${query.status}`} work? – user663031 Commented Jun 8, 2017 at 5:29
Add a comment  | 

1 Answer 1

Reset to default 20

You need to change it to the code below.

return (<UserList id={subactions} key={ `applications${query.status}` } />)
发布评论

评论列表(0)

  1. 暂无评论