React code conventions and best practices use linting and automatic formatter. Use PascalCase in components, interfaces, or type aliases. Prefer using typescript barrels A barrel is a way to roll up exports from several modules into a single convenient module.

•3m read time•From levelup.gitconnected.com
Post cover image
Table of contents
React code conventions and best practicesUse linting and automatic formatterImport orderNaming conventionsPrefer using typescript barrelsAvoid default exportComponent structureUse PropsWithChildrenSeparate function from the JSX if it takes more than 1 lineAvoid using indexes as key propsUse fragmentsPrefer destructuring propertiesSeparation of concernsAvoid huge componentsGroup the state whenever possibleUse shorthand for boolean propsAvoid curly braces for string propsAvoid using inline stylesPrefer conditional rendering with ternary operatorUse constants or enums for string valuesUse type aliasesDon’t use third-party libraries directlyRely on abstraction instead of the implementationPrefer declarative programmingUse descriptive variable namesAvoid long list of function argumentsUse object destructuringPrefer using template literalsUse implicit return in small functions
8 Comments

Sort: