Javascript .map函数';s索引中包含方法

Javascript .map函数';s索引中包含方法,javascript,reactjs,typescript,Javascript,Reactjs,Typescript,我的代码给出了以下错误: Warning: Encountered two children with the same key, `classroom-1278238`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior

我的代码给出了以下错误:

Warning: Encountered two children with the same key, `classroom-1278238`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
我使用了这两个部分。map方法。我试图将我的代码放在
和在映射内定义“索引”之间,但React JS Typescript不接受这一点

classroomFeatures.map((classroom_features: Types.ISelectOption) => {
                                        return (
                                          <React.Fragment key={'classroom_features-' + classroom_features.value}>
                                            <button className="multiple-info-tag small-tag text-capitalize">
                                              {classroom_features.label}
                                            </button>
                                            <br />
                                          </React.Fragment>
                                        );
                                      })
警告:遇到两个孩子使用同一把钥匙,
教室-1278238
。键应该是唯一的,以便组件在更新期间保持其标识。非唯一键可能会导致复制和/或忽略子项-不支持该行为,并且可能在将来的版本中更改

此处的
键应是唯一的。为密钥生成唯一值:

key={'_'  +  Math.random().toString(36).substr(2, 9)}

您在
教室\u功能
对象中有哪些属性?@SajibKhan
教室\u功能
是一个界面,包含
标签
。好吧,我猜
标签
不是唯一的!你能试试这样的方法吗:
key={Date.now()}
?我刚试过,它给出了相同的错误,但是现在相同的key就是这个Date.now值
key={'_'  +  Math.random().toString(36).substr(2, 9)}