For most cases to render children you can use this.props.children
render() {
return (
<div>
{this.props.children}
</div>
)
}
However, if you wanted to add functionality like an onClick handler to the children you can map through the children and clone them with the extra props.
Let's say you start with this:
render() {
return(
<ShoppingList>
<Item>First</Item>
<Item>Second</Item>
<Item>Third</Item>
</Shopping>
)
}
And you wanted to add an onclick to each item. Then you can use React.Children.map API and add it to each child using the React.cloneElement React API. Note the React.Children.map works differently than a typical ES6 .map. As its first argument it takes in the array that it will map through and the 2nd argument is the function applied to each element.
render() {
return (
<div>
{React.Children.map(this.props.children, child => {
return React.cloneElement(child, {
onClick: this.props.onClick })
})}
</div>
)
}
The arguments in the function applied to each element are (the_children_element, the_props_you_want_to_add_to_it).
Task Request. We Modified Our Task Request To Add Core Features & 'Communities' To Ulogs.org, Simplifying The 1.5 Task Drastically. + (500 Steem Is Completed In 7 days/550 Steem For 5 Days)
The task has been drastically simplified and the first task is partially done. Ulogs is front-end only and a fork of busy. It uses React JS. This tasks have been delayed. It has been more than a month already. Please consider helping me or please pass it on, to anyone who can help me. The time allotment for both tasks is 7 days.
https://steemit.com/utopian-io/@surpassinggoogle/task-request-we-modified-our-task-request-to-add-core-features-and-communities-to-ulogs-org-simplifying-the-1-5-task-drastically
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @positivelyzack! You received a personal award!
Click here to view your Board
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hello @positivelyzack! This is a friendly reminder that you have 3000 Partiko Points unclaimed in your Partiko account!
Partiko is a fast and beautiful mobile app for Steem, and it’s the most popular Steem mobile app out there! Download Partiko using the link below and login using SteemConnect to claim your 3000 Partiko points! You can easily convert them into Steem token!
https://partiko.app/referral/partiko
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Congratulations @positivelyzack! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit