I would like to ask someone who had experience with Shopify App development how to inject JS script into product.template.liquid under "Add to cart button" when a Toggle button is clicked from React component.
I have already set up an app using Node.js and React (Polaris framework) and I can connect and authenticate with Shopify. I also wrote the JS script that is working when I add it directly to the product.template.liquid page. Now I would like to connect these two.
The script is showing a fake count of viewers on the page.
What I would like to do is to display this script if this.state == enabled and hide the script if this.state == disabled.
Thank you very much for your help!