FRONTEND

[1. React.js] React.js File Structure (Modular)

로그앤 2023. 6. 16. 16:48

src/
  ├── components/
  │   ├── Button/
  │   │   ├── Button.js
  │   │   ├── Button.css
  │   ├── Title/
  │   │   ├── Title.js
  │   │   ├── Title.css
  │   ├── Container/
  │   │   ├── Container.js
  │   │   ├── Container.css
  ├── pages/
  │   ├── HomePage/
  │   │   ├── HomePage.js
  │   │   ├── HomePage.css
  │   ├── AboutPage/
  │   │   ├── AboutPage.js
  │   │   ├── AboutPage.css
  ├── App.js
  ├── index.js

 

Breakdown of the file structure:

 

  • The components directory contains individual component folders. Each component has its own folder with separate files for the component's JavaScript logic (ComponentName.js) and CSS styles (ComponentName.css).
  • The pages directory contains page-specific components. Each page has its own folder with separate files for the page's JavaScript logic (PageName.js) and CSS styles (PageName.css).
  • The App.js file serves as the entry point for the application. It acts as a container component that renders the different pages and components.
  • The index.js file is responsible for rendering the App component and mounting it to the root DOM element.