I am currently storing my user using react context, each user can like as many posts as they want.
i have a parameter called isLiked in my backend that can either be true
Assuming you are getting the props from parent component.
const Heart = ({ isLiked }) => {
const [ liked, setLiked ] = useState(false);
useEffect(() => {
setLiked(isLiked)
},[isLiked])
......
}
use useEffect to make sure you update your state whenever the isLiked prop changes.
Then in your parents component.
const ListofPost = () => {
const data = fetchTheData(url);
....
return ( data.map( item => <Heart isLiked={item.isLiked} />) )
}