0

I'm refactoring HTML into React. The HTML uses a purchased theme that relies on a few custom JS files including jQuery. How do I link custom scripts to components in React? Do I link them in my index.html file in the public folder? Or do I need to link them in each component file?

Brian Patrick
  • 333
  • 5
  • 18

1 Answers1

1

You can link them in the index.html or you can import them in your JavaScript. I tend to import in my root JavaScript file so that the imported files are bundled with the rest of my JavaScript (if using a bundler like webpack). For example, to include the JavaScript required for materialize I simply add require("./js/bin/materialize"); in my app.jsx file.

adam_th
  • 397
  • 3
  • 11