JavaScript / React Style Indentation

Is there a consensus for padding in React JSX? 2 spaces, 4 tabs, etc.

+4
source share
3 answers

You should use the same indentation as all javascript code.

So the ecosystem response seems to use mostly double spaces, so I would use this to ensure consistency.

+6
source

Most popular libraries tend to use 2 spaces, but you can change this if you and your team agree with the standard.

eslint, . javascript Airbnb.

+1

You must use an identity style that matches your style. You can use something like ESlint to define a convention. 4 or 2 spaces or tabs is just a style.

0
source

All Articles