DEV Community

Amlan
Amlan

Posted on

Passing Array elements through Props in React

Image description

I want to pass elements of arrayList to the User Component, through Props, and render them in a list.

The array must preset in the parent Component (let say app.js)

In App.js →
<User userList={arrayList}/>

Now We need to pass the Props through the User functional Component.

If you console.log(props) in the User.js You can see all elements of App.js And We want only arrayList of App.js,We declared the arrayList as UserList var . So If I console.log the Props.userList.I can see the arrayList elements.

Now time to render the arrayList. For this we will use Map function(know more about Map function in javascript)

Image description

Top comments (0)