- What are props and why are they used?
- Props as a way to make components flexible and re-usable
- Why prop values should never be changed within components (one-way data flow)
- How to pass props to components
- Reading props using
props.xsyntax - Reading props using destructing syntax
- Forwarding props using spread syntax
- What are children props?
- Creating wrapper components
- Conditional rendering using if/else
- Conditional rendering using ternary operator
(<condition> ? <then> : <else>) - Conditional rendering using a boolean expression
<condition> && <then>
- What is State and when to use it
- Differences between Props and State
- Introduction to React hooks
- How to declare and use State with
useState
- Updating State consisting of arrays
- Updating State consisting of an object
- What causes React to re-render components
- Using an update function for multiple State changes following after each other
- Conditional rendering using if/else
- Conditional rendering using ternary operator
(<condition> ? <then> : <else>) - Conditional rendering using a boolean expression
<condition> && <then>
- Rendering multiple items using
.map()
- Lifting state up to the parent
- Create a new component called
Button - Accept
textandonClickas props - Render a
<button>element with thetextprop as its content - Attach the
onClickprop to the button'sonClickevent handler
- Create a new component called
Card - Accept
title,description, andimageUrlas props - Use destructuring to extract the props
- Render a card-like structure with the provided
title,description, andimageUrl
- Create a new component called
Layout - Accept
childrenas a prop - Render a layout structure (e.g.
header,maincontent area,footer) with thechildrenprop rendered inside the main content area - Pass children by adding them in between the tags of the parent component
- Create a new component called
ToggleContent - Accept a
showprop as a boolean value - Accept
contentas a prop, which can be a string or a React element - Render the
contentprop only if theshowprop is true, otherwise render a message
- Create a new component called
Counter - Use the
useStatehook to manage a count state variable - Implement functions to increment (count up) and decrement (count down) the count
- Render the current count value and buttons to call the increment and decrement functions
- Create a new component called
Form - Use the
useStatehook to manage the state of form input fields - Implement a function to handle form submission, you may want to use
onSubmitin combination with a<button type="submit"> - Render a form, input fields for each form field and the mentioned submit button
- Create a new component called
Parent - Create another component called
Child - In the
Parentcomponent, use theuseStatehook to manage a state variable - Implement a function to update the state variable
- Render the
Childcomponent and pass the state variable and the update function as props - In the
Childcomponent, render the data received from the parent and a button to call the update function that changes the state