This is the least amount of code for a minimal editor in browser which can support html/css/js edit and preview kinda environment.
It goes without saying once you look at this in detail 😂 - this is not meant to be used in production setups. This can be your fun local preview playground. But the main use of this would be when you are working on a project which needs an editor/preview setup like this, you can use this setup as a trial to test things locally and then improve everything on top of it later. Although it has so many limitations it can be a good starting point for testing waters.
Check out the code within this embedded Codesandbox for more details.
I had written a gist couple of years ago in Vue.js (for this very use case to test waters in one of my side projects), recently while I was digging up all the dead things on my Github, I came across this gist. Ported it to React.js, and shared it.