Skip to content

Latest commit

 

History

History
45 lines (28 loc) · 1.68 KB

File metadata and controls

45 lines (28 loc) · 1.68 KB

Javascript Style and Conventions

React

Component Structure:

  • Organize React components using a consistent folder structure.
  • Use meaningful, file, folder, and variable names.

Functional Components

  • Prefer functional components with hooks (e.g., useState, useEffect) over class components when possible.

Component Reusability

  • 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"

Props

  • Document prop types using PropTypes or TypeScript for type safety.
  • Avoid mutating props directly within components.

State Management

  • Keep component state localized whenever possible.
  • Often react Context Api is adequate, but for complex state management see below for some libraries to consider

Conditional Rendering

  • Use ternary operators or conditional statements for legibility and clarity.

Security

  • Be cautious with the use of dangerouslySetInnerHTML.