Search code examples
javascriptreactjsreduxreact-bootstrap

Passing multiple actions to onClick event in a react-bootstrap Button


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?


Solution

  • Wrap them in another function:

    <Button bsStyle="success" bsSize="small" onClick={onButtonClick}>
      Something
    </Button>
    ...
    onButtonClick = function(event){
      someCallback()
      someOtherCallback()
    }