1

Consider a react/redux application with react-bootstrap components.

This may be a very rookie question, but I am trying to pass multiple actions to a single onClick event on a Button from a react-bootstrap library.

<Button bsStyle="success" bsSize="small" onClick={someCallback; someOtherCallback;}>
  Something
</Button>

How to do this properly?

3 Answers 3

3

Wrap them in another function:

<Button bsStyle="success" bsSize="small" onClick={onButtonClick}>
  Something
</Button>
...
onButtonClick = function(event){
  someCallback()
  someOtherCallback()
}
Sign up to request clarification or add additional context in comments.

Comments

0

You can use the following code to do more than one thing when the button is fired

function doMagic {
  //do something
  //do another thing
}
<Button bsStyle="success" bsSize="small" onClick="doMagic()">
  Something
</Button>

Comments

-1

I think there's OnClickCapture as well that works for a secondary Click Event. Probably not the most efficient way, but I think it works in the meantime if you use Onclick for the first function and OnclickCapture for the second function.

Comments

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.