Read 29 ~ Component Composition
By Abdallah obaid
NAME | URL |
---|---|
Home | Home. |
Prep | Prep: Engineering Topics. |
Read 01 | Node Ecosystem, TDD, CI/CD. |
Read 02 | Classes, Inheritance, Functional. |
Read 03 | Data Modeling & NoSQL Databases. |
Read 04 | Advanced Mongo/Mongoose. |
Read 05 | Linked Lists. |
Read 06 | HTTP and REST. |
Read 07 | Express. |
Read 08 | Express Routing & Connected API. |
Read 09 | API Server. |
Read 10 | Stacks and Queues. |
Read 11 | Authentication. |
Read 12 | OAuth. |
Read 13 | Bearer Authorization. |
Read 14 | Access Control (ACL). |
Read 15 | Trees. |
Read 16 | Event Driven Applications. |
Read 17 | TCP Servers. |
Read 18 | Socket.io. |
Read 19 | Message Queues. |
Read 26 | Component Based UI. |
Read 27 | React Testing and Deployment. |
Read 28 | Props and State. |
Read 29 | Component Composition. |
Component Composition
## react-router:
- react-router: React Router is the standard routing library for React.
- React Router keeps your UI in sync with the URL.
- react-router allows you to toggle the visibility of components (or even pages) based on the URL/Route that the user engages with
import { Route } from 'react-router-dom';
- for routing in react we use the built-in tag
<Link>
instead of<a>
.
## Specialization:
- Think about components as being “special cases” of other components. For example, we might say that a WelcomeDialog is a special case of Dialog.
## Inheritance in react:
- Facebook said: we use React in thousands of components, and we haven’t found any use cases where we would recommend creating component inheritance hierarchies.
- Props and composition give you all the flexibility you need to customize a component’s look and behavior in an explicit and safe way.