the code is as follows:
handleSwitchColor = (color) => {
console.log(color);
const {store} = this.context;
store.dispatch({
type: "CHANGE_COLOR",
themeColor: "red"
})
};
render () {
return (
<div>
<button
style={{ color: this.state.themeColor }}
onClick={() => this.handleSwitchColor}
>Red</button>
<button
style={{ color: this.state.themeColor }}
onClick={this.handleSwitchColor}
>Blue</button>
</div>
)
}
ask:
The handleSwitchColor function has been bound to button through the arrow function in the
code, but how do you pass parameters to this function in this way?
this.handleSwitchColor() //