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

Docs - sample code updates needed? #2031

Open
ahtee opened this issue May 23, 2019 · 4 comments
Open

Docs - sample code updates needed? #2031

ahtee opened this issue May 23, 2019 · 4 comments

Comments

@ahtee
Copy link

ahtee commented May 23, 2019

There seems to be confusion on how to write class components in the docs. Using this as a starting point for other pages which may need to be updated.

There is a mixture of function declaration and class components in the docs which can be confusing as when someone may want or need to use either method. Since the release of hooks, the docs should have a new site version release (similar to how Babel has site versions) with the updated, preferred way to write components backed by the core team.

in CONTRIBUTING.md, it shows that you should write classes with a constructor, but the Blog post titled "Update on Async Rendering" seems to prefer the former method of writing components.

Can this be solidified and added to the docs where necessary? Will there be a need to have a new site version with focus on function declaration components?

🥇

@alexkrolick
Copy link
Collaborator

alexkrolick commented May 23, 2019

There are 2 things here:

  • Regarding class components: In general the preference is still to use only standardized ES syntax unless specifically calling out that the syntax is still in proposal stage. Hence the recommendation to use constructor instead of class property syntax. This recommendation is not changing at the moment.
  • Regarding function components w/hooks vs classes: @rachelnabors from the core team is now leading the docs project and could probably comment on any plans to change over the recommendations to the new APIs, among other improvements and re-organizations.

@ahtee
Copy link
Author

ahtee commented May 24, 2019

thanks @alexkrolick! I'll look forward to any updates on the docs!

@jsejcksn
Copy link
Contributor

@rachelnabors:

@alexkrolick mentioned that you are leading the docs project, so will you please share your plans for updated documentation? I started learning React after the hooks API was implemented. I, too, found it confusing that many parts of the documentation explain topics only from the perspective of class components, but the hooks section encourages using function components for all new code:

Should I use Hooks, classes, or a mix of both?

When you’re ready, we’d encourage you to start trying Hooks in new components you write.
...
In the longer term, we expect Hooks to be the primary way people write React components.

@nickmccurdy
Copy link
Contributor

Duplicate of #1788

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