Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Last active November 17, 2022 16:02
Show Gist options
  • Save halitbatur/decef54b8d15050eeb7201f259285421 to your computer and use it in GitHub Desktop.
Save halitbatur/decef54b8d15050eeb7201f259285421 to your computer and use it in GitHub Desktop.
Discussion about React state, props and Events

Discussion questions about react:

Please discuss with your teams and answer these questions in your own words.

  1. What is the difference between state and props in React?
  2. When should you use state and props in React?
  3. What is the difference between stateful and stateless components in React?
  4. How can you pass props to a component in React?
  5. How does react handle events, can you write an example?
@noor-ridha
Copy link

Room 8 (Noor Ridha Ramyar Nanor Baraa and Mohammed othman
1.state is like a local variable can not be accessed or modified outside of the component
props make components reusable by giving components the ability to receive data from their parent component in the form of props.
2.Props is short for properties and they are used to pass data between React components.React has another special built-in object called state, which allows components to create and manage their own data. 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)
3.for stateful :

  1. stores data about the state of component stage in memory
  2. have authority to change the state
  3. contains history about changes in state
  4. can be used when building element that accepts user input

for stateless:

  1. calculate the internal state of the components
  2. has no authority on state
  3. contains no history
  4. can be used When creating element does not need to be interactive

5.5.React events are named using camelCase, rather than lowercase for example
Activate Lasers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment