Build a JSX Live Compiler as a React Component

Joe Maddalone
InstructorJoe Maddalone

Share this video with your friends

Send Tweet

As a tool for future lessons, we want to have the ability to write JSX and see the output live in the browser. In this lesson we will use React to build our own live JSX compiler.

Daniel
Daniel
~ 6 years ago

Looks like there is a slight type with importing the bootstrap css. The link should go to http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css instead of //netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css

Michel
Michel
~ 6 years ago

This works if you use a web server to preview the page, because using "//" uses the same protocol as was used to load the page. This won't work if you're previewing by doing "Open File" from your browser, because the protocol is "file://".

Chris Kobrzak
Chris Kobrzak
~ 5 years ago

At the time of writing this post the JSBin snippet is using React 0.14.3 and it doesn't seem to work in the browser. Adding the type="text/babel" attribute to the index.js <script> tag in index.html seems to have resolved this issue (tested in Safari 9 and Chrome Canary 49).

Seb
Seb
~ 5 years ago

Nice lesson. I love how you can just bosh out the CSS without any kind of effort or much typing because of the macros and seemingly infinite experience.

Jun
Jun
~ 5 years ago

Thank you for posting this. The type="text/babel" attribute saved me tons of time debugging.

Roland Cedo
Roland Cedo
~ 4 years ago

I'm receiving "Error in ./src/App.js Module not found: 'App.css' in path_to_project/src".

I have App.css in my src directory. A quick search on Google suggests that I'm missing a loader but I don't think the course covered any steps set up anything. Suggestions?

Chris Frewin
Chris Frewin
~ 4 years ago

Roland, I have the exact same error. I tried npm install --save-dev css-loader and npm install --save-dev style-loader, but they didn't help... did you manage to find a solution?

Roland Cedo
Roland Cedo
~ 4 years ago

Hey Chris,

I tried the exact same thing after doing some time on StackOverflow. No luck yet, hopefully we can get some admin help sometime soon. I managed to finish this course without it though. Some breaking changes in React may have happened since this was recorded.

Maxim Kazantsev
Maxim Kazantsev
~ 4 years ago

Hey Roland, Chris! I had the same issue just now and turns out if you do import './App.css', it works nicely. I assume it's a new version of Webpack or change of Webpack config in create-react-app that is causing it.

Neil Kempin
Neil Kempin
~ 4 years ago

I believe the usage of import 'App.css' is not supported in a non-ejected create-react-app app without some css loader configuration, at this time.

Anthony Buckley-Thorp
Anthony Buckley-Thorp
~ 4 years ago

I just encountered this same issue when following along. To get around it I just put the CSS in some <style type='text/css"></style> tags in the index.html file which worked fine.

yulia
yulia
~ 3 years ago

the correct import './App.css’ instead of 'App.css’; otherwise it will be error

Itamar Silverstein
Itamar Silverstein
~ 3 years ago

full of errors. first error - cannot find webpack somehow... even after npm i --save webpack and npm i --save webpack-dev-server GUYS please first test the code in vs code / atom / whatever before you push this project to git people pay money for this you know

Janis
Janis
~ 2 years ago

As of now, Aug 2019, Github repo doesn't work last I tried. Path problems with webpack or something. Didn't dig deeper I dunno webpack. Same problem as Itamar suggested above.