I have one component, that should get from api and render data with diferent variable names. I have two response with same data but with diferent variable names for example:
FirstReq {
id number
published boolean
publishDate string
newsImage string
newsText string
newsTitle string
}
SecondReq {
anons string
archived boolean
fullText string
id number
postingDate string
title string
}
Usualy i used it by variable names:
interface ItemProps {
item: {
id: number,
title: string,
fullText: string,
anons: string,
postingDate?: string,
image?: string,
},
}
const Item: React.FC<ItemProps> = (props) => {
const { item } = props;
const { id, postingDate, title, anons, image, fullText } = item;
return (
<>
<div>{title}</div>
<div>{postingDate}</div>
<div>{fullText}</div>
</>
)
}
export default Item
But how can I write component to use it with diferent variable names? variable for "text" can be "fullText" or "newsText" or "articleText" is it possible to render it in one universal component? Have no idea how to write it. Can anyone help, or give advice how to do it?