2

Just curious is it possible to do this? I know I can create a method that wrap these 2 things together but I would like to do it in one line.

<div onClick={e => this.callnotherMethod(); this.setState({toggleView: !this.state.toggleView})/>Something</div>

1 Answer 1

3

Yes, you can. But in your example you forgot to wrap function's body in {}

e => { this.callnotherMethod(); this.setState({toggleView: !this.state.toggleView}) }
Sign up to request clarification or add additional context in comments.

2 Comments

I think your first answer was correct, no need to that as you are already using arrow functions for binding
@ShubhamKhatri you're right! I totally missed it )) Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.