Search code examples
javascriptcssreactjssystemjs

Importing Libraries Into React with SystemJS


Am a new bee with React and I usually have custom css files and libraries I use for my web app development. I have been able to import my css files with require and css-loader npm install. I want to know If I can use SystemJS to import libraries like waves.js from bower_components and use it like I would in JQuery/Javascript Waves.attach(".btn:not(.btn-icon):not(.btn-float)"), Waves.attach(".btn-icon, .btn-float", ["waves-circle", "waves-float"]), Waves.init()

If it is possible how would I do this and If not how can I import waves because into my project.


Solution

  • I imported my waves.js file like so without system js and called the attach functions in the componentDidMount function and it worked like a charm

    import Waves from "../../libs/bower_components/Waves/dist/waves.min.js";
    
     componentDidMount() {
        Waves.attach(".btn:not(.btn-icon):not(.btn-float)");
        Waves.attach(".btn-icon, .btn-float", ["waves-circle", "waves-float"]);
        Waves.init();
    }