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 number3: Amal Salah, Zoriana, Ahmad Hassoun and Sakar.
1- Both hold information that influences the output of render. The difference are
a- props like function parameters, have to be passed to the component. State likes variables which are declared inside the component.
b- Data from props is read-only, and cannot be modified by a component that is receiving it from outside. State data can be modified by its own component, but is private (cannot be accessed from outside
2- Props are used to communicate between components. States can be used for rendering dynamic changes with the component.
3- A stateful component is a component that holds some state. Stateless components are those components which don't have any state at all
4- Add them to the JSX, like html. For example <component height={size} / >
5- Handling events with React elements is very similar to handling events on DOM elementsReact events are named using camelCase, rather than lowercase. With JSX you pass a function as the event handler, rather than a string