小编Drs*_*aud的帖子

如何定义反应选择中选项的最大限制?

我为我的应用程序 React 创建了一个 React 选择组件,并且有超过 70 个选项,为此我想定义用户可以选择的选项的最大限制以很好地处理它。你能帮我么?

\n

代码:

\n
export default function ReactSelect(props) {\n  const animatedComponents = makeAnimated();\n  return (\n    <Select\n      isMulti="true" // allow to select mutli options\n      isRtl="true" // right to left\n      name="name" // html name\n      options={accountsNames} // options\n      className="basic-multi-select"\n      classNamePrefix="select"\n      isSearchable="true" // searchable for the closest one\n      placeholder="\xd8\xa7\xd8\xae\xd8\xaa\xd8\xb1 \xd8\xa7\xd8\xb3\xd9\x85 \xd8\xa7\xd9\x84\xd8\xad\xd8\xb3\xd8\xa7\xd8\xa8..." // if there is no option selected\n      components={animatedComponents}\n    />\n  );\n}\n
Run Code Online (Sandbox Code Playgroud)\n

reactjs react-select

12
推荐指数
1
解决办法
1万
查看次数

React“警告:遇到两个拥有相同密钥的孩子”

我有一个 React 应用程序,映射卡并且每张卡都有唯一的 id,尽管我在控制台中收到错误,有些卡不是唯一的:

\n
\n

警告:遇到两个孩子使用同一把钥匙,2294264。键应该是唯一的,以便组件在更新时保持其身份。非唯一的键可能会导致子项被重复和/或\xe2\x80\x94 被忽略,该行为不受支持,并且可能会在未来版本中更改。

\n
\n

这是构建我的卡片结构的代码:

\n
function CreateCards(doc) {\n  return (\n    <SimpleCard\n      key={doc.newsid}\n      theCardId={doc.newsid}\n      categorietitle={doc.categorietitle}\n      newstitle={doc.newstitle}\n      date={format(new Date(doc.date), "dd/MM/yyyy")}\n      thenews={doc.thenews}\n      newsurl={doc.newsurl}\n    />\n  );\n}\n
Run Code Online (Sandbox Code Playgroud)\n

这是映射卡片的代码:

\n
      <div className="general-card1">\n        {this.state.noPlaceFound ? (\n          <h3 className="noPlaceFound">\n            <i className="fas fa-exclamation-circle fa-sm WarnIcon"></i>\n            \xd9\x84\xd8\xa7 \xd9\x8a\xd9\x88\xd8\xac\xd8\xaf \xd9\x86\xd8\xaa\xd8\xa7\xd8\xa6\xd8\xac\n          </h3>\n        ) : (\n          this.state.WasMap.map((v) => CreateCards(v._source))\n        )}\n      </div>\n
Run Code Online (Sandbox Code Playgroud)\n

你能帮我么?

\n

javascript reactjs

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

reactjs ×2

javascript ×1

react-select ×1