I believe you're on the right track. Try changing this.
<p>{item.content}</p>
To this.
<p>{item[content]}</p>
Don't forget to use content inside the component.
content
const Accordion = ({ array, content }) =>
And now in the accordion component pass a static text with the property name.
<Accordion array={blogs} content={'body'}/>
If you want to get fancy you can turn the prop content into a function.
<p>{content(item)}</p>
You could do this.
<Accordion array={blogs} content={(item) => item.body}/>
Thank you. That worked perfectly. I thought I might be close but I just couldn't get over the hurdle. Thanks
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I believe you're on the right track. Try changing this.
To this.
Don't forget to use
content
inside the component.And now in the accordion component pass a static text with the property name.
If you want to get fancy you can turn the prop
content
into a function.You could do this.
Thank you. That worked perfectly. I thought I might be close but I just couldn't get over the hurdle. Thanks