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

NataliaTepluhina picture NataliaTepluhina  路  3Comments

BingoRUS picture BingoRUS  路  3Comments

kentcdodds picture kentcdodds  路  3Comments

yazaabed picture yazaabed  路  3Comments

waruyama picture waruyama  路  3Comments