Hello Im a beginner in React have a button in a react component and I want to pass 2 options to its onClick method, something like:
handleClick = clickType => {
const {currentStep} = this.state
let newStep = currentStep
clickType === 'next' ? newStep++ : newStep--
if (newStep > 0 && newStep <= 6) {
this.setState({
currentStep: newStep
});
}
}
handleChange = input => e => {
this.setState({ [input]: e.target.value });
};
continue = e => {
e.preventDefault();
this.props.nextStep();
};
back = e => {
e.preventDefault();
this.props.prevStep();
};
<button onClick={() => this.handleClick(), this.back} className='previous'>قبلی</button>
<button form='my-form' type='submit' onClick={() => this.handleClick('next'), this.continue} className='next'>ادامه</button>
How can I achieve this correctly?
onClick={(e) => {this.handleClick(); this.back(e)}}