I have tsx file who is returning this:
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>
</>
)
my MapStateToProps is this:
const mapStateToProps = (state: ApplicationState) => ({
data: state.persons.data
});
So my question is how to put this code in mapStateToProps?:
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();
}