I am fetching some data in my App component and mapping through it to display names. I also have a counter component which besides the counts, I want to render the user names from the data fetched in App. I wish to know how do I pass the data's user names as props to the counter component so that it displays the names there as well?
Here is my App:
function App() {
const {data, isLoading} = useAsync({promiseFn: loadUsers})
if (isLoading)
return "Loading..."
if (data)
return (<div className="container">
{
data.map(user => (
<div key={user.username} className="row">
<div class="col-md-8">
<div class="card-body">
<h2>{user.name}</h2> // Need this to also display in button component
<Counter id={user.name}/>
</div>
My Counter Component's return :
return (
<div>
<b>Would you like to work with (user.name data from app) </b> <i onClick={handleIncrement} class="far fa-thumbs-up" style={clickStyle}> Yes!</i>
<br/>
<h><b>{count}</b> have said Yes!</h>
</div>
);
}