Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React.Component undocumented templated class #9684

Closed
barbu110 opened this issue May 14, 2017 · 9 comments
Closed

React.Component undocumented templated class #9684

barbu110 opened this issue May 14, 2017 · 9 comments

Comments

@barbu110
Copy link

I see that React.Component is used with three template parameters that are documented nowhere. (or I simply couldn't find the docs).

I was able to deduce that the second and third are the types of props and state respectively. However, I coudn't figure it out about the first template parameter.

Are these documented anywhere, please?

@Hypnosphi
Copy link
Contributor

Hypnosphi commented May 14, 2017

Kinda. The first parameter is the type of defaultProps. Note that currently you can't use intersection types (like CommonProps & {foo: Foo}) for this.

@barbu110
Copy link
Author

Could you please point me to the internal source file that defines class Component<...>? I couldn't find it...

@Hypnosphi
Copy link
Contributor

Hypnosphi commented May 14, 2017

It's in Flow codebase, weirdly: https://github.com/facebook/flow/blob/master/lib/react.js#L16. I guess this is because React codebase is yet only partially typed

@barbu110
Copy link
Author

barbu110 commented May 14, 2017

Strange thing. Thank you very much!

I will try to work on a PR to update the documentation. It's pretty confusing when you try to get deeper into React

@gaearon
Copy link
Collaborator

gaearon commented May 14, 2017

React documentation doesn't have a section about Flow (should it?) So I am not fully sure where you would like to document this.

However, there is a section about React on the Flow website. Does it not help?

@barbu110
Copy link
Author

@gaearon the section about React on the Flow website is a guide and it does not present the entire API reference.

And yes, I think React should have a section about Flow. Currently, the React docs section Typechecking with PropTypes explains that

React.PropTypes is deprecated as of React v15.5.

In my opinion this comes as a way to encourage the usage of TypeScript or Flow for static typechecking. Hence, this is part of the reason why there should be a Flow section in the React documentation. What do you think?

@gaearon
Copy link
Collaborator

gaearon commented May 14, 2017

The wording on React doc is really unfortunate. It shouldn't say "deprecated", it should say "moved". We're not deprecating PropTypes—just moving them to a separate package.

Although I agree that in general we think Flow/TS is a better way to do it. I'm open to having a new guide called "Static Type Checking" here that shows how to use React from Flow and from TypeScript, and describes main API definitions. Would you like to work on it?

@barbu110
Copy link
Author

@gaearon, yes, I would like to help as much as I can!

@bvaughn
Copy link
Contributor

bvaughn commented Oct 8, 2017

Thank you for filing this issue! 😄

The documentation and source code for reactjs.org now lives in a different repository: reactjs/reactjs.org. (For more info on why we made this move, see issue #11075.)

I've moved your issue to the new repo: reactjs/react.dev#76

Let's continue the discussion there! Sorry for the inconvenience.

@bvaughn bvaughn closed this as completed Oct 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants