Naming conventions - React Native

 Naming conventions play a important role to improve code readability, maintainability, organization, and communication. 


1. Pascal Case

+ First letter of each word is capitalized
+ No spaces or punctuation marks between the words
+ Using pascal case for below elements:
  • React native component.

  • Enumerations (Enums)

2. Camel case

+ Each word begin with a capital letter except the first word, which starts with a lowercase letter
+ Using camel case for below elements:
  • Variable names

  • Function name

  • Object properties

  • Custom hooks 
    eg: useBottomSheet()

  • Higher order component(HOCs)
    eg: withAuthenticate()

3. Snake case

+ Uppercase letters, with words separated by underscores("_")
+ Using snake case for below cases:
  • Constants

  • Enumeration properties (properties name in snake case)

  • Global variables

4. Higher order component

+ Use "with" as Prefix
+ Use "Original component" as Suffix

5. Custom hooks

+ Use "use" as Prefix
+ Use "Behaviour of hook" as Suffix

6. Others

+ Use more descriptive and specific names
  • Shouldn't:

  • Should:

+ Choosing singular or plural naming

+ Avoid excessive abbreviations
  • Shouldn't:
  • Should:

Reference:

Kumar, S. N. (2023, May 14). Part 1: Naming Conventions - The Foundation of Clean Code, 

DEV Community, https://dev.to/sathishskdev/part-1-naming-conventions-the-foundation-of-clean-code-51ng









 

0 Comments