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?
馃
There are 2 things here:
thanks @alexkrolick! I'll look forward to any updates on the docs!
@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鈥檙e ready, we鈥檇 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.
Duplicate of #1788
Most helpful comment
@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: