Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 16, 2022 02:15 pm GMT

How not to write clean code in React?

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

Useful links

How to not become a better developer

Connect with me


Original Link: https://dev.to/avneesh0612/how-not-to-write-clean-code-in-react-4b7p

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To