react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Missing docs about Transferring Props in JSX

Open hellobrian opened this issue 9 years ago • 3 comments

(Originally opened in https://github.com/facebook/react/issues/11124#event-1282129854)

I noticed that the latest docs don't talk about Transferring Props in JSX with rest properties.

/* for example */
render() {
  const { children, ...other } = this.props;
  return <button {...other}>{children}</button>
}

☝️ I felt that this was really useful for building reusable react components and an important concept to surface on the main docs. I was curious if omitting this documentation was intentional? If so, it would be great to understand why (maybe this isn't a good practice anymore?).

Otherwise, I would be happy to send a PR that adds this back into the docs with any changes you and the community want to see. Overall, I just think this is important info to surface in the current docs.

Thanks!

hellobrian avatar Oct 10 '17 00:10 hellobrian

On the JSX in Depth section of the docs there's a header called Spread Attributes. It isn't exactly what you mention though since it doesn't show how you can pluck some properties out and pass through the rest.

Would you be interested in submitting a PR that adds an additional example to this section?

bvaughn avatar Oct 10 '17 15:10 bvaughn

Yes, I can send a PR - thanks for the quick response!

hellobrian avatar Oct 10 '17 15:10 hellobrian

This issue is all yours! 😄

I've added an "in-progress" label so that others will know not to start work on the issue. If you change your mind about the issue, no worries! Just let me know so that I can remove the label and free it up for someone else to claim.

Cheers!

bvaughn avatar Oct 10 '17 16:10 bvaughn