๐—ฅ๐—ฒ๐—ฎ๐—ฐ๐˜.๐—ท๐˜€ ๐—–๐—น๐—ฒ๐—ฎ๐—ป ๐—–๐—ผ๐—ฑ๐—ฒ ๐—ฃ๐—ฟ๐—ฎ๐—ฐ๐˜๐—ถ๐—ฐ๐—ฎ๐—น ๐—จ๐˜€๐—ฒ

Write better React code with these six rules.

  1. Separate data from your view Keep your JSX clean. Do not mix data fetching with your UI. Move your logic into a custom hook. This makes your component easy to read and test.
  1. Manage form state efficiently Avoid creating a new useState for every single input field. This makes your code messy as your form grows.
  1. Set default values for optional props When you use optional props, always provide a default value. This prevents bugs when a prop is undefined.
  1. Clean up your imports Organize your files so imports stay short and clean.
  1. Use built-in array methods Stop writing manual loops for simple tasks. Use standard JavaScript methods to keep your code readable.
  1. Use constants for magic numbers Never use random numbers in your logic. If a status is 0, nobody knows what that means.

Source: https://dev.to/kkr0423/reactjs-clean-code-practical-use-10kg