Putting it all together
Here are the main steps of building a React App:
-
Define Component Hierarchy:
- Divide the page into components where each part of the page to do a specific task is considered a seprate component (kown as single responsibility principle), when a component is growing too big, it is good to think of dividing it to sub components.
-
Build A Static Version in React:
- Where you will have a model of your design but with no interactivity.
-
Identify Interactive Data
- As long as needed, data needed for interaction will be stored in
state
not props
.
-
Where to Add State?
- Data needed for a component shall live in it or on a higher level component (remeber one way data flow)
-
Data Flow in Opposit Direction
- Define what kind of interaction needed from child to parent and pass functions that
setState
as aprop to the child.