Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run sandbox code #108

Open
avinashhasule opened this issue Nov 18, 2018 · 2 comments
Open

Unable to run sandbox code #108

avinashhasule opened this issue Nov 18, 2018 · 2 comments
Labels

Comments

@avinashhasule
Copy link

Hello ,
I tried same to execute code by downloading code from sandbox download link .
While running exception gives Unexpected token @track.

@tizmagik
Copy link
Collaborator

Hi @avinashhasule you need to ensure you have your babel configured to transpile the decorator syntax. See here: https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy

@tizmagik
Copy link
Collaborator

Ah, I see what you mean now, just downloading the sandbox code and running it locally won't work because react-scripts (what create-react-app uses for its build configuration) doesn't support decorators. I'm honestly not entirely sure why it works in the web view of CodeSandbox but not when you download it, I think maybe they use TypeScript to compile or something?

Anyway, here's a few workarounds for developing locally:

Depend on decorators-react-scripts (instead of react-scripts), in package.json:

-    "react-scripts": "1.1.4",
+    "decorators-react-scripts": "2.1.3",

Or, use CRA via TypeScript, https://facebook.github.io/create-react-app/docs/adding-typescript (TypeScript can be configured to support @decorators)

Or, use craco to add decorators support to create-react-app without ejecting.

Or, eject from create-react-app and add the babel decorator plugin manually. I wouldn't recommend this approach if all you're adding are decorators.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants