I am using JQuery with ReactJS. When clicking on the button, the first click does nothing. However, on the second click the action I am trying to achieve does work. But it's an every other click win.
I've tried adding $(document).ready() inside of the openSubscriptionModalFromButton function. This doesn't fix the issue.
I am for sure passing in openSubscriptionModalFromButton to my components.
I've researched .click on Jquery docs, and I've also read the articles saying to not use Jquery in React ;).
** In the landing component, the button I want Jquery to click (see id)
<button
id="right-top-corner-button_upgrade"
>
UPGRADE/LANDING
</button>
** In the Toolbar - a modal pops up to ask if you want to upgrade.
openSubscriptionModalFromButton() {
$('#right-top-corner-button_upgrade').click()
this.closeDialog() // closes the Modal pop-up on after the click
}
** In the Modal from Toolbar
<button
onClick={() => props.openSubscriptionModalFromButton()}
>
Upgrade/Toolbar
</button>
Right now I'm just console logging 'click' and on the 2'click' (second click), it works.
I'm expecting the upgrade/toolbar button to open the modal on every click, instead of every other.
Appreciate any help. Thank you!