I am trying to find a smarter way to loop through an array and generate jsx and return to the render function:
renderCardImages = () => {
const cards = [
'Visa',
'MasterCard',
'AmericanExpress',
'Discover',
'JCB',
]
return (
)
}
render () {
return (
{renderCardImages()}
)
}
How do I achieve this? I believe render is called only once.
Answer
return (
{card.map(c=>(( ))}
)
No comments:
Post a Comment