I'm including this Stack Overflow thread since I've been relying on it heavily for this situation, but I'm not quite sure how to get the syntax right for my case.
Of the multiple solutions provided in that thread, here's one example of how to make an onClick
with multiple functions:
<a href="#" onClick={(event) => { func1(); func2();}}>Test Link</a>
Trying to apply this situation of an onClick
with multiple functions to my code, I have this:
<span className={mobileMenuClass.join(' ')}
onClick={(event) => {this.toggle.bind(this); this.togglePopup.bind(this)}}>
<span id="menu-rect-top"></span>
<span id="menu-rect-middle"></span>
<span id="menu-rect-bottom"></span>
</span>
This doesn't cause any errors, but neither of the two functions fire.
I first had the onClick written with one function, like this:
onClick={this.toggle.bind(this)}
...which did work, but once I added the second function, both no longer worked. Trying this with the other function...
onClick={this.togglePopup.bind(this)}
...also works as expected.
I think I can give this onClick
a single handleClick
function, like this:
onClick={handleClick()}
...but also not sure how to work with these two bind
s that are needed for these functions.