mardi 23 juin 2020

In react I have JQuery npm and I have used JQuery in my chart-custom.js file but still getting jQuery undefined error

but still getting a jQuery undefined error while chart-custom.js file appending.

import React, { Component } from 'react';
import axios from 'axios';
import $ from 'jquery';

class Dashboard extends Component {
 componentDidMount(){
    const jQuery = $;
    console.log(jQuery); //JQuery working fine.

    //for safer side I have also used local jquery 
    let alpha = document.createElement("script");
    alpha.src = require('../assets/js/jquery.min.js');
    alpha.async = true;
    document.body.appendChild(alpha);

    let script = document.createElement("script");
    script.src = require('../assets/js/chart-custom.js'); //error In this line
    script.async = true;
    document.body.appendChild(script);
  }



Aucun commentaire:

Enregistrer un commentaire