So, let's dive right
into this video and this topic by answering
the most important question first.
What exactly is React.js and why would we use it?
Why do we need it?
What's the problem it helps us solve?
Regarding the what, we can, of course, visit reactjs.org,
the official webpage of React.js.
And there, we learn that React is a JavaScript library
and it's a JavaScript library for building user interfaces.
Now, that's quite straightforward.
It's a library for the JavaScript programming language
that helps us build user interfaces.
But what exactly does this nice sentence mean?
React.js is a library and, to be precise,
it's a client-side library.
It's about client-side JavaScript.
So, the JavaScript code, which runs
in the browsers of your visitors.
And that is important because we use JavaScript
in the browser to manipulate web pages
after they were loaded, and that allows us
to build rich, highly interactive,
modern user interfaces for our websites.
Take something like Netflix, for example,
which is actually built with React.
There, we can browse around, we can hover over one
of the movies or series, and we get more details there.
We can add it to our list, and we can go to that list page
and everything here happens very smoothly,
and also quickly.
We never need to click anywhere, and load a new HTML page.
That refresh icon, in the top left corner, never spins
Because we never request a new HTML page,
we never have to wait for a new HTML page
to be generated by the server.
And that happens because JavaScript is doing some work here
and it's updating what we see on the screen,
the dom, whilst we are working on that page.
And that gives us that nice user experience,
that nice UI, which we know from mobile apps, for example.
When we work with a mobile app,
we're used to things being very reactive.
There, we can work with the app and switch
between different screens without having that latency,
which we know from some websites,
without requesting new HTML pages behind the scenes.
So, mobile apps therefore feel very reactive,
things happen instantly, we don't need to wait
for new pages to load, or for actions to start.
And, traditionally, in web apps that was different.
There, we often had to click a button
and then wait for a new page to be loaded and to show up.
And whilst that, of course, also does work
it is not the same user experience our users know
from their mobile apps, and it's often not
the user experience we want to deliver therefore.
Now, that's a problem we can solve with JavaScript,
JavaScript in the browser, because that allows us
to manipulate the dom and therefore what the user sees
without requesting a new HTML page and waiting for it.
And therefore, just JavaScript would be enough.
But let me give you an example
of just JavaScript and why we might want
to use something like React instead of just JavaScript.