[Docs] Add Example For React.Children.map
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
For https://reactjs.org/docs/react-api.html#reactchildrenmap to help illustrate as to what it does, can we kindly add an example for something like this.
const Value = ({ value }) => <p>{value}</p>
const PropsInjector = ({ children }) => React.Children.map(children, child => {
return React.cloneElement(child, { value: 'some_value' });
});
const App = () => (
<PropsInjector>
<Value />
<Value />
</PropsInjector>
)
I don't know if this might be an acceptable example for React.Children.map, but I would love to hear some feedback if possible.
The current documentation doesn't have a an example on how React.Children.map can be used & it doesn't make sense for someone like me
As per docs: React.Children.map(children, function[(thisArg)])
For someone like me I got very confused
function[(thisArg)]when I read this & didn't know on how I could use it.
I am more then happy to make a PR for adding this example & or any better example if someone can suggest.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the React.Children.map section of the documentation page linked in the issue and review the existing API explanation and examples. Add a clear React usage example based on the requested child-prop injection scenario, with wording that explains the callback argument; done when the page demonstrates how React.Children.map can be used without the current confusion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100