Implementei a função, porém quando vou dar like ele da erro dizendo que o login nao existe, segue o código:
class FotoInfo extends Component {
constructor(props){
super(props);
this.state = {likers: this.props.foto.likers};
}
componentWillMount(){
PubSub.subscribe('atualiza-liker', (topico, infoLiker) => {
if(this.props.foto.id === infoLiker.fotoId){
const possivelLiker = this.state.likers.find(liker => liker.login === infoLiker.liker.login);
if(possivelLiker === undefined){
const novosLikers = this.state.likers.concat(infoLiker.likers);
this.setState({likers:novosLikers});
}else{
const novosLikers = this.state.likers.filter(liker => liker.login !== infoLiker.liker.login);
this.setState({likers:novosLikers});
}
}
});
}
render(){
return (
<div className="foto-in fo">
<div className="foto-info-likes">
{
this.state.likers.map(liker => {
console.log(liker);
return (<Link key={liker.login} href={`/timeline/${liker.login}`}>{liker.login},</Link>)
})
}
curtiram
</div>
<p className="foto-info-legenda">
<a className="foto-info-autor">autor </a>
{this.props.foto.comentario}
</p>
<ul className="foto-info-comentarios">
{
this.props.foto.comentarios.map(comentario => {
return (
<li className="comentario" key={comentario.id}>
<Link to={`/timeline/${comentario.login}`} className="foto-info-autor">{comentario.login} </Link>
{comentario.texto}
</li>
);
})
}
</ul>
</div>
);
}
}
O que poderia ser?