AI Hints
Home›React Tutorial›Frameworks and Habits
React · Lesson 87 of 120

Best Practices

Everyday habits.

⏱ 2 min read▶ Video at 1:14:09🎓 Free
Watch this lesson in the React courseWatch on YouTube ↗Full React course

Good React code isn't clever. It's small components, minimal state, and data that flows in one clear direction.

  • Not clever
  • Small and minimal
  • One direction

Everyday habits

Keep components small, and give them clear names. Keep state minimal, and derive everything else. Put state as low as possible, but as high as needed. And prefer composition over long lists of options.

keyvalue
Componentssmall, well named
Stateminimal
Placementas low as possible
Reusecomposition

Tools that help

Use TypeScript to catch mistakes early. Turn on the hooks linter. Format with Prettier, so nobody argues about style. And use strict mode in development, which runs effects twice to expose bugs.

keyvalue
TypesTypeScript
Linteslint hooks plugin
FormatPrettier
Dev<StrictMode>

Summary

Small components, minimal state, and good tools make React code easy to live with. Next, debugging.

Key takeaways
  • Small
  • Minimal state
  • Good tools
Next up: Debugging — React DevTools