Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to include external javascript in react

In an html page you can include a javascript file by <script src="path"></script> How do you get variables from an external path like this in react, if the path is, for example: <script src="https://unpkg.com/[email protected]/dist/flux-sdk-helpers.min.js"></script>

Thanks for all your help

like image 673
amaclean Avatar asked Feb 02 '26 00:02

amaclean


1 Answers

Scripts loaded in that fashion normally install themselves as global variables and/or properties of some other global library.

According to the docs, flux-sdk-helpers installs itself as a global variable FluxHelpers when you install it this way.

This means your React code can access it as either FluxHelpers or window.FluxHelpers.

like image 107
Brandon Avatar answered Feb 03 '26 14:02

Brandon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!