🌎
Web Map
  • Web map
  • Denormalized Data
  • V2 web map
  • Customizable web map
  • Like
  • User profile
  • Wallet app
  • SEO
  • Search
  • The Wallet Web Application
  • V1 Implementation Timeline
  • React Coding Practices
  • Denormalization Migration
  • CSS and MaterialUI Guideline
  • Tile Server Specification
  • Search
    • Solr research
    • Config web map beta
Powered by GitBook
On this page

Was this helpful?

React Coding Practices

There is no such a thing as "perfect" code, there is always a chance for "better" code 💻

PreviousV1 Implementation TimelineNextDenormalization Migration

Last updated 4 years ago

Was this helpful?

  • Folderize Your Components (related files in one folder)

  • Componentize Your Code

    • Each file should fix to small functionality (each with a single responsibility)

    • Create many utility files that can help remove duplicate code from multiple files

  • Naming Conventions

    • Name your file logically according to the job that they perform

    • React UI component's name should be PascalCase (UpperCamelCase)

    Example: WalletSlider.js
    • All other helper files should be camelCase

    Example: commonUtils.js
    • CSS files should be named the same as component PascalCase. Global CSS (applies to all components) should be placed in global.css and should be named in camelCase

    Example: WalletSlider.css (for component), global.css (for global styles)   
    • Test files should be named after the component or non-component file

    Example: WalletSlider.test.js

  • Other

    • Destructuring your props is a good way to help make your coder cleaner and more maintainable.

      Example: (async function authenticate({user_id, token}){})
    • Use useReducer when useState becomes complex.

Always review your code before creating a pull request.