Read 28 ~ Props and State
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.
———————————-
Props and State
## State:
- The state object is where you store property values that belongs to the component. When the state object changes, the component re-renders.
## Props:
- You can pass any JavaScript expression as a prop, by surrounding it with {}.
- React Props are like function arguments in JavaScript and attributes in HTML.
- To send props into a component, use the same syntax as HTML attributes.
- Equivalent of function params.
- In actuality, props is the name of the object passed into a component constructor and any prop added to a component in the JSX will be accessible as a property on props.
- Props can be data or functions.
## One Way Data flow:
- In the One Way Data flow State can only be passed from parent component to a child component through the use of props.
- State can only be passed down the component tree (not up).
- If the child want to pass data to parent he need to invoke a function sent from the parent.