Which component should be included in the states ??!

In React, we have a lots of component that is placed in the form of parent and child.
Now the question that arises
Which component should be included in the states ??!
Component higher or lower?
.
Let me first explain the state
States specify the status of the application
For example, if you click on a button and a page opens and the status of the application has changed, it means that one of the states has changed.
.
Now the answer to the question is that there is a general rule
That is, if you need to read or even change the state in the higher-order component , you must define it in the higher-order component.
Of course, there are exceptions to this rule, but it helps a lot
.


Building reuseable component

hello guys
I was saying we should try to reduce our duplicate code
And if we feel something is repeated many times, we should make it a component

it is clear , that in this screen some thing is creating over and over again

Now it is clear , that in this screen a square with a shadow that has an icon and a title is repeated several times.
But in a series of detail that are icons and titles are different
The easiest way to write all this with one component
It is to create a component for that square and give its style
And take the square title and its icon from its parent as a props
And call the Item component several times
And each time it is used
according to where it is
Give its Suitable icon and title props


1 tip for clean code

take a brief look at the pages
And in similar places , Instead of coding several times, make a component

Hello guys
One of the most important features that React provides to its programmers
is the reusable component
Whenever you feel that a piece of code
is running several times
Just make it a component
And call the created component several times
And it helps a lot to keep your code clean
One of the things that must be done first
in any project, is to take a brief look at the pages
And in similar places , Instead of coding several times, make a component and use it several times
.
For example, on the next slide, I put the headers of several…

Amirprogrammer

React native developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store