You are using map
instead of filter
, if you did not return something in your map function, it will return undefined
as your item in your new array.(您使用的是map
而不是filter
,如果您没有在map函数中返回任何内容,它将返回undefined
作为新数组中的项目。)
You can write your render as the following, you always return <RenderOverview>
component, and if there is a selected option, filter your work
based on the selected option, otherwise use back the original work
list.(您可以按以下方式编写渲染,始终返回<RenderOverview>
组件,如果有选定的选项,请根据选定的选项过滤work
,否则请使用原始work
列表。)
return (
<RenderOverview
work={selectedOption ? work.filter(value => value.pure_taxonomies.types[0].name === selectedOption.label) : work}
/>
);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…