mercredi 17 juillet 2019

Best way to pass in a React component?

I was hoping to get some advice for best practices / design patterns to use to pass in a component into another component. My example is, I have a page that has a list component which iterates through a map and renders an items detail component. I would like to reuse this list component but when it's on different pages, render the data with different item details components. The one requirement is that, the child component takes in the list item as props and renders it.

My second question is, this child component has a button to delete itself. Should this be a callback function passed in from the "page" component or the list component?

Aucun commentaire:

Enregistrer un commentaire