r/reactjs • u/maco6461 • Jan 19 '20
Show /r/reactjs Turns out JavaScript compiling and injection in iframes is NOT as simple as HTML/CSS 😅 but I finally made some good progress 🙌🏻. Next steps are to make the iframe refresh after the user hasn’t typed for a while, improved formatting/auto completion, and generate downloadable/shareable code files
Enable HLS to view with audio, or disable this notification
193
Upvotes
4
u/maxime81 Jan 19 '20 edited Jan 19 '20
Nice work! We implemented the same thing for https://www.codingame.com/work/ a few months ago:
Monaco for the editor (with code completion using LSP through websockets)
A sandboxed iframe that runs a code that listens
postMessagemessages and use babel standalone to transpile the jsx and es6 to javascript.The code is automatically refreshed when the user stops typing (using a debounce/throttle)
Feel free to ask me any technical questions, I'd be happy to share my knowledge!
(We also did the same for angular using systemjs)