-
ESLint uses Airbnb's ESLint configurations for styles and conventions, the full style guide from Airbnb can be read here.
- Organize React components using a consistent folder structure.
- Use meaningful, file, folder, and variable names.
- Prefer functional components with hooks (e.g.,
useState,useEffect) over class components when possible.
- Design components to be reusable and single-responsibility.
- Implement component composition to combine small components into larger ones.
- Any shared components can be extracted into a "Common Component"
- Document prop types using PropTypes or TypeScript for type safety.
- Avoid mutating props directly within components.
- Keep component state localized whenever possible.
- Often react Context Api is adequate, but for complex state management see below for some libraries to consider
- Use ternary operators or conditional statements for legibility and clarity.
- Be cautious with the use of
dangerouslySetInnerHTML.