1 00:00:00,000 --> 00:00:03,072 In this stage, I introduced you to props. 2 00:00:03,072 --> 00:00:08,173 Props are a way to pass data from one component to another in React. 3 00:00:08,173 --> 00:00:12,802 They allow us to customize and configure components dynamically. 4 00:00:12,802 --> 00:00:18,721 By passing props, we can control the behavior and appearance of our component. 5 00:00:18,721 --> 00:00:20,680 To use props in a component, 6 00:00:20,680 --> 00:00:26,573 we simply added a parameter named props to the function representing the component. 7 00:00:26,573 --> 00:00:32,404 This props parameter allows us access to the data passed from the parent component. 8 00:00:32,404 --> 00:00:36,470 We successfully passed props to the Header, Item, and 9 00:00:36,470 --> 00:00:41,588 Counter components, allowing them to receive and utilize the data. 10 00:00:41,588 --> 00:00:46,737 With the Item component now accepting props, we were able to leverage 11 00:00:46,737 --> 00:00:51,725 the power of the map method to generate a list of items efficiently. 12 00:00:51,725 --> 00:00:54,454 By iterating over an array of items, 13 00:00:54,454 --> 00:01:00,184 we dynamically created a list of Item components based on the data provided. 14 00:01:00,184 --> 00:01:04,571 This approach enabled us to scale our application easily, 15 00:01:04,571 --> 00:01:07,738 handling any number of items in the array. 16 00:01:07,738 --> 00:01:11,372 When creating lists of components using map, 17 00:01:11,372 --> 00:01:16,412 React requires us to assign a unique key prop to each component. 18 00:01:16,412 --> 00:01:19,709 The key prop helps React efficiently update and 19 00:01:19,709 --> 00:01:23,591 manage the list of components whenever changes occur. 20 00:01:23,591 --> 00:01:29,411 It's crucial to provide a stable and unique identifier as a key prop, 21 00:01:29,411 --> 00:01:33,269 such as a unique ID associated with each item. 22 00:01:33,269 --> 00:01:37,873 Our grocery list app is starting to take shape, but it's still static. 23 00:01:37,873 --> 00:01:42,561 The items displayed never changes because we're passing a static 24 00:01:42,561 --> 00:01:44,326 list of items to our app. 25 00:01:44,326 --> 00:01:48,259 And the counter doesn't change an item's quantity. 26 00:01:48,259 --> 00:01:50,566 Remember, props are read-only. 27 00:01:50,566 --> 00:01:54,813 So in order to add dynamic behavior and interactions, 28 00:01:54,813 --> 00:01:57,594 our app needs data that can change. 29 00:01:57,594 --> 00:02:03,462 A web application's UI is normally a function of the data you put into it. 30 00:02:03,462 --> 00:02:08,320 In other words, changes in your data result in changes to the UI. 31 00:02:08,320 --> 00:02:14,077 And when changes are made to the UI, your data changes in response. 32 00:02:14,077 --> 00:02:18,915 In the next stage, we'll explore the concept of state in React components. 33 00:02:18,915 --> 00:02:20,916 State allows us to store and 34 00:02:20,916 --> 00:02:26,050 manage information within a component that can be altered over time. 35 00:02:26,050 --> 00:02:28,628 We'll learn how components, props, and 36 00:02:28,628 --> 00:02:32,500 state work together to build interactive React applications.