Skip to content
Advertisement

props are not working when using map method in react.js

props are passing fine when we are passing them as a whole array of objects but it is not working when I am passing the props by traversing through the array using map function.

JavaScript

in the above code props are passing when I am passing manually in Cardimg component…but as soon as I start using map then it doesn’t work…like the props are not reaching the component.

below is my Cardimg component

JavaScript

Advertisement

Answer

You need to return the Cardimg component inside map callback function.

Either like this

JavaScript

Or like this

JavaScript
Advertisement