Implementation — Part I 

📚  Choosing a React Component Library

💡 Why a Component Library? Advantages: - High-quality components: Our previous button has 0 interaction states - Take care of basics: Extensibility + Easy to use + Accessibility - We can customize them as we wish - Advanced teams out there who are working a full-time job to have this components ready to use - Free!
 
Material UI has by far the highest community out there and it’s backed up by the Google team ⇒ Best React component libraries

Install [ Docs ]

npm install @mui/material @emotion/react @emotion/styled
 

Cleanup

  • Exercise: Replace our button to be MuiButton instead [ API docs ]
    • Add color, size and variant props.
    • Replace CSS properties with your preferred style approach, e.g. emotion or tailwind. Find here a list of libraries you can use with MUI
 
→ Find our implementation in the section below “Download code”
→ Find our implementation in the section below “Download code”
 

📖  Best Practices for Writing Reusable Components

When developing innovative applications, it is important to follow best practices for writing reusable components. Doing so ensures that your codebase is maintainable, scalable, and efficient. Here's why this is important from a high-level perspective:
  1. Maintainability 🛠️: By writing components that are encapsulated and self-contained, you make your code easier to understand, debug, and update. This reduces the likelihood of introducing bugs when making changes.
  1. Efficiency ⏱️: Reusable components save development time and resources by reducing the need to write similar code multiple times. This allows you to focus on building new features rather than reinventing the wheel.
  1. Consistency 🎨: Using reusable components promotes a consistent look and behavior across your application, enhancing the user experience and making the application easier to manage.
  1. Collaboration 🤝: Well-defined components enable multiple developers to work on different parts of an application simultaneously without conflicts, improving team productivity.
  1. Scalability 📈: As your application grows, a library of reusable components helps you quickly develop new features while maintaining code quality and performance.
 
For a deeper dive into the principles of component reusability and best practices, check out our detailed blog post: Component Reusability Principles Part I.
 
 

⬇️  Download code [ 🔗 Link ]