简体   繁体   中英

Using Skulpt with React

I'm interested in creating a React web app that teaches kids how to use Python through programs such as Turtle graphics. I thought that Skulpt would be a good library to use since it already has a demo that shows here how to use it within a HTML page. However, while it loads fine in a normal web page, I'm having difficulty getting it to run in my React app, probably due to the global variables that skulpt.min.js sets. Specifically, I get the following message:

./src/utils/skulpt-stdlib.js
Line 1:1:  'Sk' is not defined  no-undef

I imagine it's because the skulpt-stdlib.js script relies on the skulpt.min.js script to be read first and set its global variables before the skulpt-stdlib.js script works. What would I need to do in React to get this to work the same way it does in a normal web page? Thank you!

try this, hope this works, i am also trying, i will update this if it works completely.

add the below code in the beginning of skulpt.min.js

function Sk() {}

and the below code in the end of skulpt.min.js

export { Sk };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM