let arr;
for (var i = 0; i < 4; i++) {
arr.push(
<ListItem key={i}> // native-base component
<Button
onPress={this.pick(curJob, i)}>
</Button>
</ListItem>
)
}
render(){
return (
{ arr }
)
}
In this code, what is the difference between the two functions?
Function 1.
pick = (job,index) => {
console.log(job);
console.log(index);
}
Function 2.
pick = (job,index) => () => {
console.log(job);
console.log(index);
}
I found that function 2 works fine but function 1 returns error (maximum call stack size exceeded) I wonder what is the difference between the two functions and if function1 can be called call-back function.