All right, it's time to learn about Hucks now, the very first thing that we need to answer is what
are hucks?
Well, if we take a look at the documentation, there's a section here that says what is a hook?
And we see over here that hooks are a function that let you hook into Riak state and life-cycle features
for function components.
Hooks don't work inside classes, and that's the thing, all hooks are, is if we go to our container.
The app, James, let's minimize this.
There you go.
The app, James is using a class component and remember, hooks are a way for us to avoid using classes
so that we can avoid the super keyword, that this key word that some people find confusing, even things
like component did mount that these life-cycle hooks that sometimes can get confusing.
So hooks allow us to use functional components which remember, we have talked about our components
are functional components right there, just functions that render something.
But before Hooke's, we only created functional components once when we didn't have any state inside
of them, all these components are what we call just presentational components, right?
They just returned something.
They just received props and returned some sort of a view.
But any time we wanted to use state, we had to convert those functions into a class component so that
we can do this Dotts state and declare our state with Hooke's.
What you get is that you can now add state to a function.
So because we have a version sixteen point eight or higher overreact, we can convert this app class
into a function.
Now, here's a thing I want you to practice reading documentation here.
Oftentimes, whenever we are introduced to a new concept, our default is to, hey, let's go find a
tutorial online.
Let's go buy a course that teaches us this.
But the best resource is usually the documentation.
The documentation is created by the people that actually created REACT, actually created the Hooke's
API.
So they usually have good resources for you to learn and use.
So as an exercise before we dive into the next video and I show you how we can start converting this
with hooks, I want you to go into the hook section of their REACT documentation and see if we can figure
out how to keep this up the exact same way that it is.
It still works.
You can still search through your robot friends, but you convert this class app into a functional component.
And instead of having things like constructor or component did amount to just convert this all into
using hooks.
I'll give you a little hint.
In order for us to do this, we'll have to import two things.
From react that we now have available, because we've updated one, is something called use state,
which is a hook, so it's called the use state hook and the other one is called the use.
Which is another hook, you see hooks essentially give us that they give us hooks like this from the
Riak Library for us to implement and use inside of our functional component to finally have state and
life-cycle methods.
So if you want to give it a go and convert this into a functional component that uses hooks.
Go ahead.
Otherwise, I'll show you how to do this in the next video.
Papy.