0

I want to use this library in my React application: http://propeller.in, but it's built on jQuery. I have added the following relevant code in my Index.js React component:

import $ from 'jquery';
import 'propellerkit/dist/js/propeller.js';

I've also tried this:

import 'jquery/dist/js/jquery.js';
import 'propellerkit/dist/js/propeller.js';

I've made sure both node modules are installed. For some reason, I keep getting a $ is not defined error.

3
  • You can try import * as $ from 'jquery'; but since I did not I didn't find it worthy of a top level answer. Commented Aug 15, 2017 at 13:27
  • Thanks, but same error. Commented Aug 15, 2017 at 13:29
  • Did you try import * as $ from 'jquery/dist/js/jquery.js'; or just import 'jquery';? That should expose jQuery as a "global" in the dist webpack creates. Commented Aug 15, 2017 at 13:31

1 Answer 1

1

If you are using webpack to bundle, you can provide jquery using ProvidePlugin,

new webpack.ProvidePlugin({
  $: 'jquery',
  jQuery: 'jquery'   // this will try to find node jquery module
})

Link to docs

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

2 Comments

Perfect. Thanks!
can you let me know how can I add a plugin in web pack in create react app...?

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.