Please discuss with your teams and answer these questions in your own words.
- What is the difference between state and props in React?
- When should you use state and props in React?
- What is the difference between stateful and stateless components in React?
- How can you pass props to a component in React?
- How does react handle events, can you write an example?
Team 5: Aland, Ruba, Ali, Shad
.Like
1-props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function).
2-Props are used to pass data, whereas state is for managing data.
3-In React, a stateful component is a component that holds some state. Stateless components, by contrast, have no state. Note that both types of components can use props.
4- Props are the information that you pass to a JSX tag. For example, className, src, alt, width, and height are some of the props you can pass to an
" <Avatar person={{ name: 'Lin Lanying', imageId: '1bX5QH6' }}" => props passing
" function Avatar({ person, size })" => props decleration
" alt={person.name} " => props Calling
5- React js handles events same as HTML with different syntax like for a button ( "<button onclick="activateLasers()"">
Activate Lasers
) in the HTML, and for React it's written in that way ( "<button onClick={activateLasers}">
Activate Lasers
)