1

I am new in React JS. I have started with React Boilerplate.
I have a js file and want to use that file globally, so whenever I was trying to add a js file with script tag <script src='' type='text/javascript'></script> in index.html, it throwing an error

Uncaught SyntaxError: Unexpected token <.

So any suggestion?

Note: Import js file in each component is working but I don't want to include it in every component repeatedly. I don't have any knowledge on webpack.

1
  • Check the src file for syntax error. This error is thrown usually when you miss tags or brackets. Commented Sep 17, 2018 at 7:12

1 Answer 1

2

You can put JS File in assets folder, then import it in App.js

import ExternalJS from '../assets/externaljs.js';

This will be available in index.js.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.