I'm creating a "profile card" component using an array and the map()
function to render data dynamically instead of hardcoding it. I'd like each person's profile to have a different border color, so I'm attempting to pass the color as a prop to the styling of the component. In the array, there is a color
key with one HEX value per person. I'm passing it down as a prop
from the array. What I'd like to do is make something like style={{border: '1px solid props.color'
but I'm not sure how to do so. Please let me know if you have any ideas!
CodePudding user response:
Use template literals. Something like this: style={{border: `1px solid ${props.color}`}}
CodePudding user response:
You could just add a template literal to add the prop to the string, e.g.
style={{border: `1px solid ${props.color}`}}