Code Fellows courses Notes
This project is maintained by QamarAlkhatib
Conditional rendering in React works the same way conditions work in JavaScript. Use JavaScript operators like if or the conditional operator to create elements representing the current state, and let React update the UI to match them.
In HTML, form elements such as < input >, <textarea >, and <select >
typically maintain their own state and update it based on user input. In React, mutable state is typically kept in the state property of components, and only updated with setState().
We can combine the two by making the React state be the “single source of truth”. Then the React component that renders a form also controls what happens in that form on subsequent user input. An input form element whose value is controlled by React in this way is called a “controlled component”.
In React, sharing state is accomplished by moving it up to the closest common ancestor of the components that need it. This is called “lifting state up”
Containment: Some components don’t know their children ahead of time. This is especially common for components like Sidebar or Dialog that represent generic “boxes”. Specialization: Sometimes we think about components as being “special cases” of other components.
Props and composition give you all the flexibility you need to customize a component’s look and behavior in an explicit and safe way.
Step 2: Build A Static Version in React
Step 3: Identify The Minimal (but complete) Representation Of UI State
Step 4: Identify Where Your State Should Live
Step 5: Add Inverse Data Flow