如何在 MapStateToProps 中映射道具?

问题描述

我有返回此文件的 tsx 文件

return (
<>
<Container>
data.map((item,i) => {
                let fullNameLetters = item.fullName.substring(0,2);
                if (item.fullName.indexOf(' ') > 0) {
                  fullNameLetters = item.fullName.split(' ')[0][0].toupperCase() + item.fullName.split(' ')[1][0].toupperCase();
                }
                return (
                  <Card {...item} key={i} nameInitials={fullNameLetters} content={item.content} />
                );
              }) 
</Container>
</>
)

我的 MapStatetoProps 是这样的:

const mapStatetoProps = (state: ApplicationState) => ({
  data: state.persons.data
});

所以我的问题是如何将此代码放入 mapStatetoProps 中?:

data.map((item,2);
                if (item.fullName.indexOf(' ') > 0) {
                  fullNameLetters = item.fullName.split(' ')[0][0].toupperCase() + item.fullName.split(' ')[1][0].toupperCase();
                }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)