Clean code isn't code that just works. It refers to neatly organized code which is easy to read, simple to understand and a piece of cake to mainta...
For further actions, you may consider blocking this person and/or reporting abuse
you are the best man .
Great article!
A little complain about conditional rendering in React: Even though ternary expression is the best solution I know, these brackets still makes my code looking like a mess. And I really love the
v-if
directive in vue, which surprises me a lot at first glance.You can use this as a type for your components that use children:
Well remembered, the setter of useState is already memoised, no need to wrap in a usrCallback.
Thanks for the article @ruppysuppy and the tips @lukeshiru
I am in love with the variable name 'truthyProp' lol
I think one of the weird thing Software Developers develop over time is admiration towards amazing variable names. Whenever I name one or see one, I get so happy and obsessed over it XD. It gives such a pleasurable feeling haha
A really good writeup.
Thanks for this article.
I like the fact that you made bad examples and good examples, so I can see the "me" now, and the "me" I ought to be 😁.
For point #7 I would even add:
"Don't set unneeded falsey values, as they render as attributes in HTML"
instead of
which would eventually render into:
leave it as undefined:
so it can skip the attribute in the HTML
Dope list thanks for creating it!
This is really nice
Nice!
`import { ReactNode ,FC } from "react";
interface ComponentProps {
children: ReactNode;
}
const Component:FC = ({ children }) => {
// ...
};`
This seems more sensible
fwiw, you shouldn't be using interfaces unless you want to enhance a type.
e.g.:
Very well written, thanks. However on point no. 3. When you have a simple component you won't be using else where, doesn't it make sense creating it in the same file instead of a whole new file?
Several tips are naive.
Thank, great solutions.
Fenomenal tips @lukeshiru
Good one!
Awesome, and really useful. I learned some new things, but my favorite was "Use TS-free TSX as much as possible"
Agree with third one. in some cases(when it's over used), that makes a project too complicated.
damn good answer, thanks! now I have an argument to explain my actions in the code. if I had just read the article, then there would be less such argumentation.