142
rated 0 times
[
143]
[
1]
/ answers: 1 / hits: 18425
/ 8 Years ago, fri, december 23, 2016, 12:00:00
I have two functions that look like this:
primaryImageLoaded () {
this.setState({primaryImageLoaded: true})
}
secondaryImageLoaded () {
this.setState({ secondaryImageLoaded: true })
}
They are called like this(using react):
onLoad={this.secondaryImageLoaded.bind(this)
This feels excessive and I would like to have just one function and pass the state-variable as a parameter, but how can I pass an additional argument to .bind
? and is it possible to use a variable as key in the object i'm passing to setState
?
More From » reactjs