I try set a new value state like this on my render()
:
this.state.contributionsList.map(function(item, i) {
this.setState({
listUsers: item.login
})
});
Also did like this:
let usersByRepo = this.state.contributionsList.map(function(item, i) {
this.setState({
listUsers: item.login
})
});
If I run console.log(item)
I have all my itens that I need. But If I add this information to my state, I get as feedback that my TypeError: Cannot read property 'setState' of undefined
. Why?
I have intention to do it, because I will send this result as a prop
to my component. But I still with this problem.
- 1) Why this happen?
- 2) What is the best method to solve this?