我有一个组件,它使用Reaction-Redux的useSelector
钩子来检索Reduxstore 中的词典.字典是UUID到包含我正在呈现的数据的对象的映射.
interface IComponentProps {
id: string
}
const Component: React.FC<IComponentProps> = (props) => {
const dataMap = useSelector((store: IRootState) => store.data.value)
return (
<div>
<h1>{dataMap[props.id].title}</h1>
<p>{dataMap[props.id].description}</p>
</div>
)
}
我有一个分派方法,它向redux存储中的数据字典添加一个新的键-值对.
假设我有这<Component />
个的倍数,以及另一个<ComponentTwo />
,它调度方法来添加一个新的键值对.当分派方法发生时,我所有的<Component />
个都将重新呈现,尽管我不希望它们的透视标题和描述保持不变.有什么方法可以让我禁用重现功能吗?