Table of contents
Introduction
Wassup everyone, long time no see. Today we will see a few ways to not clean code in React, let's jump right into it!
10 ways to not write clean code
Not use a linter
Who needs a linter to keep good code styles, and keep the code clean when you can define the rules as you go. ๐จ
Add everything in one file
Just put everything in one file, so you don't need to create many different files and components and can have 1000s of lines in one file. The compilation build time will also be very small if you use just a single file! ๐
Write duplicate code
Why reuse variables, and components when you can copy-paste the same code over and over again and if you need to change one small thing then spend a ton of time adjusting it everywhere. So productivity++ ๐
Have unused imports/variables everywhere
Why care to delete the unused variables and import them when they can stay where they are and increase your app bundle size. ๐
Prop drilling
Just keep passing props 10 components deep because who wants to use a tool to manage state properly ๐ฅฑ.
Not destructure objects
Who cares about destructuring objects, keep doing {object.a}
, {object.b}
everywhere. ๐ง
Not using typescript
Who needs to use typescript when you can pass a number for name
somewhere and string for the same variable somewhere ๐คทโโ๏ธ
Not using enums
Who doesn't love typos!? Why use enums when you can make a typo and mess up your entire code base and pull your hair for 2 days to find the error after breaking production ๐คก
Use random names for functions, variables, components
Why waste time thinking about a great function/variable/component name, use a random name and save time. ๐ฐ
Conclusion
I hope you were able to understand how not to write clean code, now it is up to you to choose if you wanna write good code or bad code! That's it for this one โ๏ธ