React js 表单字段名称和 refs 连接

React js form field names and refs with concatenation

您好,我正在尝试像这样连接表单字段名称和引用并返回 jsx

<select className="lp-country" id="lp-country" name = 'country'{i} ref = 'country'{i} >

其中 i 是循环的索引。我收到意外的令牌错误。

代码截图:https://www.screencast.com/t/8QILiZaBGMM

错误截图:https://www.screencast.com/t/ITZPH6BVT

String interpolation 那里没有正确使用。

替换

name = 'country'{i} 

name = {`country${i}`}

ref 相同。