React · Lesson 87 of 120
Best Practices
Everyday habits.
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.
| key | value |
|---|---|
| Components | small, well named |
| State | minimal |
| Placement | as low as possible |
| Reuse | composition |
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.
| key | value |
|---|---|
| Types | TypeScript |
| Lint | eslint hooks plugin |
| Format | Prettier |
| 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