How not to write clean code in React? ๐Ÿงน

How not to write clean code in React? ๐Ÿงน

Avneesh Agarwal
ยทJun 16, 2022ยท

2 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

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!

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 โœŒ๏ธ

How to not become a better developer

Connect with me

Did you find this article valuable?

Support Avneesh Agarwal by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
ย 
Share this