0
0
Reactframework~5 mins

Using props in JSX in React - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are props in React?
Props are inputs to React components. They are like function arguments and let you pass data from a parent component to a child component.
Click to reveal answer
beginner
How do you access props inside a functional component?
You receive props as a parameter in the function and access them using dot notation, like props.name.
Click to reveal answer
beginner
What is the JSX syntax to use a prop called title inside a component?
You use curly braces to embed JavaScript expressions: {props.title} inside the JSX.
Click to reveal answer
intermediate
Can props be changed inside a component?
No, props are read-only. You cannot modify them inside the component. To change data, use state or pass new props from the parent.
Click to reveal answer
beginner
How do you pass a string prop called color with value blue to a component Box?
You write: <Box color="blue" />. This passes the string 'blue' as the color prop.
Click to reveal answer
How do you pass data from a parent to a child component in React?
AUsing local variables
BUsing state inside the child
CUsing CSS
DUsing props
Inside a functional component, how do you access a prop named 'message'?
Aprops.message
Bthis.message
Cstate.message
Dmessage()
What is the correct JSX syntax to display a prop called 'name' inside a component?
A<props.name>
B{props.name}
C"props.name"
D(props.name)
Can you modify props inside a React component?
AYes, props can be changed anytime
BOnly if you use setState
CNo, props are read-only
DOnly in class components
How do you pass a number prop 'age' with value 30 to a component <User>?
A<User age={30} />
B<User age="30" />
C<User age='30' />
D<User age=(30) />
Explain how props work in React and how you use them inside a functional component.
Think about how you give information to a child component.
You got /4 concepts.
    Describe why props are read-only and what you do if you want to change data inside a component.
    Consider data flow and component responsibility.
    You got /4 concepts.