OK.
Once we have learned what are the class based components there's probably a ten thousand dollar question
that you already ask.
Well which component should I use and my most simplest answer would be like this.
You see as you're noticing and react as you saw already with using let's say arrow functions whether
that would be implicit or explicit return which by the way would be javascript thing but still I'm including
this and react as well as as you are looking at the imports and exports as we're looking right now at
the components.
There's a simple answer and it's called preference.
I have seen where people use everything with the class based component because you can do pretty much
everything that you're doing already with functional but you can also add your state.
I have seen where people are using the functional components wherever they want meaning whenever they
don't want the state or the lifecycle methods because they prefer the actual syntax they say that you
know what I like how this looks much simpler than dealing with the class and in general there should
be a performance benefit that they react as promised but at the moment to tell you honestly I am not
aware of them and this is gonna be the case where this is really up to you if you like the Functional
Component use them all over the place and then whenever you need a state you're just going to have to
be creating the class component.
However I do want to warn you that if you're going this route there's going to be a times when you already
finish your component you're like oh shoot I do need my state and then you're going to have to refactor
it for me.
If you're going to be using hooks by the way again not just as a side note that I need to add that if
you're going to be using Hooks you're going to be doing probably a functional component anyway and then
you're gonna be setting it up if you need it.
So I do need to add it but we're going to be focusing on these two options either the class based or
the functional component and that might be a sometimes a pain where you need to refactor everything
from the functional to a actual class based.
So from the other side the easiest one would be doing everything with the class based components because
then you don't need to worry about anything you know that if you want state I'm gonna have a state.
If you just want a simple return your is gonna get a simpler.
Now in this course again I'm going to be switching back and forth.
There's gonna be some cases where we're just creating a class based component even though we don't need
to.
There's gonna be cases where if I know that there's not going to be a state I will gonna be having this
as a functional component when I refer back to the simple fact of preference.
If you have a different preference if you think that well I don't want this to be a class based component
just make it a functional it is really up to you.
Again I don't think that in general this is going to matter whatever choice you're choosing the moment
where there's performance benefits.
Sure but at the moment we all have our preferences.
So some people like the syntax simpler like this.
Some people think that classes are good enough and they don't want to refactor it so that would be the
simpler stanzas that I can give you of which component you should choose.
Of course if you're gonna be working with functional component and you do need to state as well as you
need to lifecycle methods you will going to have to reach for a class based component or react.
There is no other choice.
However if you don't need it then again this is just gonna be your preference.