Codesandbox-client: How can you use jQuery's $?

Created on 18 Dec 2017  路  1Comment  路  Source: codesandbox/codesandbox-client

I'm trying to create a React sandbox with the following code:

declare const $: any;

This works in my own codebase without having to do anything special. I get an "Unexpected token, expected" error, though.

How can I get use jQuery in CodeSandbox and get $ to work?

Most helpful comment

Heya! You can use jQuery by doing something like this:

import $ from 'jquery';

// Now you can use $

or you can add jQuery (https://code.jquery.com/jquery-3.2.1.min.js) under External Resources under Dependencies in the sidebar.

We have plans to add better support for custom aliases, so that would make it possible to do this in the future.

>All comments

Heya! You can use jQuery by doing something like this:

import $ from 'jquery';

// Now you can use $

or you can add jQuery (https://code.jquery.com/jquery-3.2.1.min.js) under External Resources under Dependencies in the sidebar.

We have plans to add better support for custom aliases, so that would make it possible to do this in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlessandroAnnini picture AlessandroAnnini  路  25Comments

CompuIves picture CompuIves  路  26Comments

Enjoy2Live picture Enjoy2Live  路  20Comments

YarivGilad picture YarivGilad  路  22Comments

faceyspacey picture faceyspacey  路  44Comments