Confused Buyer

Choose 4 Toys

Barbie

Price: $377

Boy Toy

Price: $348

Bus

Price: $623

Car

Price: $211

Doll

Price: $82

Football

Price: $82

Teddy Bear

Price: $743

Train

Price: $852

Water Gun

Price: $276

Selected Toys


Q.1 How does React Work?

React is a JavaScript library for building user interfaces. It works by creating a virtual representation of the user interface called the Virtual DOM. When data in a React component changes, React compares the new Virtual DOM with the previous one, identifying the differences (diffing). It then efficiently updates the real DOM to reflect these changes, minimizing the need for manual DOM manipulation. This approach improves performance by reducing unnecessary re-rendering and enhancing user experience in web applications. React also encourages a component-based architecture, making it easier to manage and maintain complex UIs.

Q.2 Differences between Props and State in React?

Props (Properties):(1) Props are immutable data passed from a parent component to a child component.
(2) They are read-only, meaning the child component cannot modify its props.

State:(1) State is mutable data managed within a component.
(2) It is used for storing component-specific data that can change over time.