ReactJS use a ready-made template (from template monster)

15 views Asked by At

I'm learning to build a project in ReactJS with Typescript at the moment.

I have bought an HTML template from templatemonster. This is a very good template and has all the UI items I need to use for my project.

I have tried to import this to my ReactJS project.

I have successfully loaded all the css of the template and have made it look almost like it should for a start.

The issue is that the template from templatemonster is using two javascript scripts

core.min.js and script.js that need to be loaded as they control how some of the view items are working. Like how the accordions are opening/closing. Some of the animations, ui stuff in forms etc.

I load them using useEffect in my Header component:

Example:

    useEffect(() => {
        const script = document.createElement('script');

        script.src = "../js/core.min.js";
        script.async = true;

        document.body.appendChild(script);

        return () => {
            document.body.removeChild(script);
        }
    }, []);

I'm getting the following error for those scripts:

ReferenceError: $ is not defined

Is there any way to load a javascript file in react that won't have an issue with $?

0

There are 0 answers