This repository was archived by the owner on Mar 4, 2020. It is now read-only.
Access modifiers and order of members in React components #936
Labels
vsts
Paired with ticket in vsts
Access modifiers and order of members in React components
The goal of this issue is to come up with certain guidelines and best practices for writing React components when it comes to:
1. Leveraging TypeScript functionality of access modifiers (
protected
,private
) and using them for React class componentsArguments for:
public
by default and it won't be detected by the linter if we don't use theprivate
modifier);Arguments against:
We need YES / NO decision and maybe enforce a eslint rule?
2. Enforce a convention for ordering methods within a component
a. React convention:
described here:
render
methodlooks like the generic convention adopted by the React community
b. TypeScript / OOP convention:
simplified version (static members come before instance members):
we're writing TypeScript code so we should take this into account when making a decision;
is having events handlers before
render
method a good way to structure it necessarily?One might argue that when you read the code you want to start with the entry points (the public methods,
render
in this case) and continue to scroll down as if it was a story, without too many jumps to the private methods that are called from the public ones (and constructor, that would also be placed at the beginning of the class).(full comment here)
We need a. / b. decision and maybe enforce a eslint rule or install this plugin?
The text was updated successfully, but these errors were encountered: