Let’s take a look under ReactJS’s skirt

Srecko Kostic
2 min readNov 12, 2021

--

How does it look like? How does all this component code look when the browser gets to see it? Is it like seeing that cute girl out on the street, but in relationship it’s a different person, it’s time to find out.

Photo by Majestic Lukas on Unsplash

The first impression

We have components, that are transformed by babel because browser doesn’t understand this syntax.

ReactJS code before compilation

And result?

ReactJS code after babel compiles it and it is writen in separate file

Demystifying ReactJS, ES5

On react documentation page, it was mentioned that react is usable with ES5.

More about what CDN is: https://stackoverflow.com/questions/47284414/can-i-do-everything-with-react-js-just-using-cdn-libraries-without-any-installa

html page using react es5 by cdn links

This is how this html file looks when opened in browser.

result in browser of html page using react es5 by cdn links

This is interesting for me because, babel output used React.createElement. Documentation also refered to this when mentioning es5 syntax.

So, what If I link babel output with src tag from my index html?

html page linking to compiled reactjs code

In the browser.

result in browser of html page linking to compiled reactjs code

Conclusion

What we are used to work with, helps us use fancy syntax and folder structures and beautiful components. The setup abstracts away — (removes the need for us to know what is done with the code we write) all of this from us to make work easier. Anyway, not all of us need to know about this, just curious ones.

You may find complete code here: https://github.com/srele96/under-reactjs-skirt

--

--

Srecko Kostic
Srecko Kostic

Written by Srecko Kostic

I create content from my perspective on topics I learn. Some information may be incorrect, but I hope some find my content useful.

No responses yet