I'm stuck with a problem on my ReactJS code causes an onClick
error that I can't understand.
<button onClick={this.apiGetProductPicture(this.props.categorie)}>{this.props.name}</button>
If I write it like this (with no parameters it works)
<button onClick={this.apiGetProductPicture()}>{this.props.name}</button>
But with parameters, the function works when I load the page and do not need to click...
An example of how I give the parameter.
<ProductItem name={"Boulangerie"} categorie={0} />
I already search but don't understand why function start without permission.
Function:
apiGetProductPicture(i) {
console.log('apiGetProductPicture');
var json = myApiGet('https://******')
// TODO do something with the data
.then(json => this.setState({ pictures: json.content.categories[1].background }))
.catch(error => console.log('home2', error));
}