jquery - How to use semantic-ui in react with webpack? -
i use commonjs include semantic-ui in react jsx file. installed semantic-ui bower, , webpack correctly configured include bower_components directory.
however, when use require('semantic-ui/dist/semantic-ui.js')
in jsx file, console throw error "uncaught referenceerror: jquery not defined", when put statement var jquery = require('jquery/dist/jquery.js')
before that.
another related thing in order semantic-ui work, semantic.css should included. wondering how include semantic.css in jsx file.
as css you're going want load in index/whatever.html file before sourcing js.
try following before require semantic-ui:
var $ = jquery = require('jquery/dist/jquery.js'); window.jquery = $; // assure it's available globally. var s = require('semantic-ui/dist/semantic-ui.js');
not 100% sure work it's worth try.
things can tricky commonjs modules. also, might worth looking react+browserify. makes super simple import npm modules using require
.
Comments
Post a Comment