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!

10 ways to not write clean code

Not use a linter

Who needs a linter to keep good code…


This content originally appeared on DEV Community and was authored by Avneesh Agarwal

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


This content originally appeared on DEV Community and was authored by Avneesh Agarwal


Print Share Comment Cite Upload Translate Updates
APA

Avneesh Agarwal | Sciencx (2022-06-16T14:15:04+00:00) How not to write clean code in React? 🧹. Retrieved from https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/

MLA
" » How not to write clean code in React? 🧹." Avneesh Agarwal | Sciencx - Thursday June 16, 2022, https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/
HARVARD
Avneesh Agarwal | Sciencx Thursday June 16, 2022 » How not to write clean code in React? 🧹., viewed ,<https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/>
VANCOUVER
Avneesh Agarwal | Sciencx - » How not to write clean code in React? 🧹. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/
CHICAGO
" » How not to write clean code in React? 🧹." Avneesh Agarwal | Sciencx - Accessed . https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/
IEEE
" » How not to write clean code in React? 🧹." Avneesh Agarwal | Sciencx [Online]. Available: https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/. [Accessed: ]
rf:citation
» How not to write clean code in React? 🧹 | Avneesh Agarwal | Sciencx | https://www.scien.cx/2022/06/16/how-not-to-write-clean-code-in-react-%f0%9f%a7%b9/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.