[英]JavaScript/React Style Guide Indentation
Is there an agreed-upon convention for indentation in React JSX?在 React JSX 中是否有一致同意的缩进约定? 2 spaces, 4 spaces, tabs, etc.
2个空格、4个空格、制表符等
You should just use the same indentation as the rest of your javascript code.您应该使用与其余 javascript 代码相同的缩进。
That said react ecosystem seems to use mostly double spaces so I'd use that for consistency.也就是说,react 生态系统似乎主要使用双空格,所以我会使用它来保持一致性。
Most popular libraries tend to use 2 spaces, but you can change this if you and your team agree on a standard.大多数流行的库倾向于使用 2 个空格,但如果您和您的团队就标准达成一致,您可以更改此设置。
You can setup up eslint so that your code base is standardised.您可以设置eslint以便您的代码库标准化。 I would definitely recommend you to take a look at one of the most popular javascript style guide by Airbnb .
我绝对会推荐你看一看Airbnb最流行的 JavaScript 风格指南之一。
The react source code and sample code in the React tutorial use 2 spaces . React教程中的 react源码和示例代码使用了2 个空格。 Also it seems like many of the Github projects related to React use 2.
此外,似乎许多与 React 相关的 Github 项目都使用 2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.