0

Following the answer to this question I tried to import jQuery using import {$, jQuery} from 'jquery';. and am getting the error Uncaught TypeError: (0 , _jquery.$) is not a function in the browser. Am using Babel with the ES2015 preset to transpile my Code. If I use two separate imports i.e. import $ from 'jquery'; import jQuery from 'jquery' then it works fine. Why can't I use the combined syntax?

1 Answer 1

2

Because import $ from 'jQuery' is short for import {default as $} from 'jQuery'. If you import {$, jQuery}, those are two names that are not exported. You can however use

import {
    default as $,
    default as jQuery
} from 'jQuery';
Sign up to request clarification or add additional context in comments.

Comments

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.