A React Take on The Notorious B.I.G.’s 10 Crack Commandments
Great music is timeless. Often times, great rap lyrics can still be relevant today and even re-interpreted to fit other topics. What if we take a great song, such as Ten Crack Commandments by The Notorious B.I.G. and apply it to starting off with React development? Allow me to help you get your game on track, and not your wig pushed back.
1. Never let no one know how much dough you hold.
Keep the props that your component expects to a minimum and make sure you use them individually. Do not just blindly spread the props object as you may cause unnecessary re-renders.
2. Never let them know your next move.
Keep your components generic enough that they solve only one view element, really well. If your components are small and flexible, then they will not be pigeonhole’d and able to be composed into larger units.
3. Never trust nobody.
Maintain an extremely high code coverage through automated testing and use static code analysis tools such as ESLint to make sure your classes are written and performing to the highest standard.
4. Never get high on your own supply.
Do not try to create every single component or feature on your own. Chances are there’s an implementation available from the open source community that may be better written, tested, and supported.
5. Never sell crack where you rest at.
It may be tempting to repeat known patterns that you applied earlier for a new feature. Do not unless it’s necessary, take a moment and see if there’s a better approach that may be a bit more challenging but worthwhile.
6. That god damn credit, dead it.
This applies to when you’re building a team around React and its ecosystem. The libraries and practices that you will be leveraging are constantly changing. You may have experienced developers on your team, but if they’re stubborn and unwilling to learn they may not be an ideal fit for the role that their seniority implies.
7. Keep your family and business completely separated.
When developing your application separate your concerns. Simply put, keep your business logic out of the view layer.
8. Never keep no weight on you.
Your render() method should be as lightweight and fast as possible.
9. If you ain’t getting bagged, stay the f*** from police.
This relates more to the tech community today. Don’t get into heated discussions or debates with developers who use competing frameworks and libraries, it’s never productive.
10. A strong word called consignment.
Don’t jump at every new and shiny library that is coming out. While you’re still getting comfortable with React and its ecosystem, focus on making sure you have a good grasp of the core library and whatever else you are using. Afterwards you can make educated decisions on changing the tooling.
These interpretations came out of a talk I did at NYC.JS on Migrating Web Apps to React. You can see the slides below. If you think I’m dead wrong (get it?) about some of these or have some ideas of your own please post them in the comments below.