Laptop Corner

Choose your favorite Laptop

Name: Apple-Macbook

Price: 100000

Name: Lenovo-Yoga

Price: 85000

Name: HP-Ellitebook

Price: 62000

Name: Dell-inspiron

Price: 55000

Name: Asus-Expertbook

Price: 43000

Name: Acer-Ferrari

Price: 52000

Name: Walton-Passion

Price: 30000

Name: Fujitsu-Lifebook

Price: 49000

Name: Samsung-Sens

Price: 70000

Selected Laptop

Question: How React works?

Answer of this question

Answer: React is a library that helps you build user interfaces. It is declarative, which means that you describe the UI as a declarative list of components. React components are reusable, which means that you can write code once and use it on many different pages. When an update is needed in the UI, only the component that is tasked for that specific update needs to be called.React makes it painless to create interactive UIs.

Question: Props vs state?

NumberPropsState
1Props are Immutable.State is mutable.
2Used to passed data from parent to child.Used within the component (limited to current component)
3Used to pass data as well as callback functions as props. Initialize within constructor
4Can get initialize from parent component and can be changed from a parent component Used “this.setState” to update object.
5Can set initialize the value for child component and can be changed in the child component Can set initialize the value for child component and can be changed in the child component

Question: How useState works?

Answer of this question

The useState() is a Hook that allows you to have state variables in functional components. useEffect runs after every render (by default), and can optionally clean up for itself before it runs again. To create a functional component and throw some React hook at it that tracks state, can also update it, and it just works. That was a lot to process and this is just a very simplistic approach to useState.