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?
Banel - Maryam Salah - Nina - Zeynab Hamad
State is local and can not be modified nor accessed outside the component but can be modified using this.setState so it means it can only be modified locally. While props on the other hand, can make your components reusable because it can pass down component data from the parent component.
Default props can be used to define any props that you want to be set for a component, whether or not a value is actually passed in from the parent component. When using default props, you can still override the values specified in the default props object when you pass in values from the parent component.
function functionName({ name, argument }) {
whatever is passed is available here
}
the difference between react and vanilla javascript is that in react we use camel case ex. onclick(javascript) onClick(react)
function developer(){
function intro(){
alert("My Name is Slim Shady and I am a Rapper");
}
return click me