본문 바로가기

개발/React

React JS naming convention

Project name

name can no longer contain capital letters.

the reason why I wrote this post 🤣

Components

PascalCase (capitalizing the first letter of each word) for component names.)

Files

PascalCase, matching the component name.

Props

Use descriptive names for props to clearly indicate their purpose.

** Avoid abbreviations or acronyms unless they are widely understood in the context of your project.

For example - instead of usr, use user.

State variables

Prefix state variables with is, has, or should to denote boolean values.

Event handlers

Use handle as a prefix for event handler functions. 

For example, handleClick, handleInputChange.

CSS classes

Use lowercase letters and hyphens for CSS class names.

Constants

Use uppercase letters with underscores to represent constants in JavaScript.

For example, API_URL, MAX_RESULTS.

Utility functions

use camelCase for utility functions or helper functions.

 


Ref :

 

 

React JS - Naming convention

In computer programming, a naming convention is a set of rules for choosing the character sequence to be used for identifiers that denote variables, types, functions, and other entities in source code and documentation. (source: Wikipedia) When it comes to

www.linkedin.com

'개발 > React' 카테고리의 다른 글

[React] 프로젝트 시작 & git repository 연결  (1) 2024.05.21