reactjs - 当复选框选中过滤数据时做出反应
问题描述
如果您正在搜索游戏,则在游戏页面上,页面将重定向到搜索结果页面。我想在搜索结果页面上进行过滤。当我选中复选框时,数据将被过滤。
json格式在这里
{"id": 26,
"title": "ebirth",
"sortName": "",
"isFullyOptimized": false,
"steamUrl": "",
"store": "",
"publisher": "",
"genres": ["Action", "Simulation"],
"status": "AVAILABLE"}
我有一个备用菜单组件,有复选框。当我在这里选中复选框时,我希望按类型和状态过滤到我的搜索结果。从此处搜索结果返回的数据
{gameIds.length > 0 && (
<div className="search-result__content">
<div className="search-result__title">
<h2>Search Results</h2>
<span>{data.filter(({ id }) => gameIds.includes(id)).length} results</span>
</div>
<div className="game-card__content">
{data
.filter(({ id }) => gameIds.includes(id))
.map((item, i) => {
return (
<a key={i} href={item.steamUrl} className={item.steamUrl && "has-url" ? "has-url" : ""}>{item.title}</a>
);
})}
</div>
</div>
)}
我怎样才能做到这一点?
这是代码
解决方案
推荐阅读
- azure - 我应该使用什么天蓝色后台进程?
- csv - 如何在 Neo4j 中与 Neo4j 中的两个 csv 条目匹配的两个节点之间创建一条边?
- haskell - 什么是度量?
- google-chrome - 谷歌浏览器不显示 fontawesome 的图标
- java - 计划任务中发生意外错误。:java.lang.NoSuchFieldError:ADJUST_DATES_TO_CONTEXT_TIME_ZONE
- c# - 反序列化 JSON 时遇到问题(预期单个值时得到值数组)
- docker - Docker容器在一段时间后挂起,无法在容器上执行任何命令
- ios - 动态密钥时如何解析API响应中的数据?(目标-C)
- android - Android Q 版本握手期间的 SSLV3_ALERT_CERTIFICATE_UNKNOWN
- python-3.x - 如何将熊猫系列元素传递给另一个数据框