This is bad in many levels... First, all the functions require a parameter that is not used anywhere, then there's this setLoading that doesn't set the loading state, instead it toggles it. Also, since it's React, it's also toggling in a way that can lead to a race condition, i.e. problems... The proper way would be passing a function to setState.
Then, you have two functions that essentially do the same thing (set a value to a variable) that could be just a single function with a parameter (which is NOT the unnecessary event parameter). Those functions don't follow a predictable naming convention and the cherry on top is that both have the same typo...
i removed the two functions later, left it there for screenshot purpose.
Thanks for your advice anyway. You were right about the event parameter. I actually notice it for a while but forgot to remove it because i created the new function by copy paste the old function and left it there.
As of the typo, i actually notice that this is quite common in the project i am working on. value -> vaule, loading -> loding etc etc .
2
u/diego_fidalgo Dec 24 '21 edited Dec 24 '21
This is bad in many levels... First, all the functions require a parameter that is not used anywhere, then there's this
setLoadingthat doesn't set the loading state, instead it toggles it. Also, since it's React, it's also toggling in a way that can lead to a race condition, i.e. problems... The proper way would be passing a function tosetState.Then, you have two functions that essentially do the same thing (set a value to a variable) that could be just a single function with a parameter (which is NOT the unnecessary event parameter). Those functions don't follow a predictable naming convention and the cherry on top is that both have the same typo...
7
u/TheBrainStone Dec 23 '21
JS devs are the mad hatters of our time
1
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Dec 23 '21
Image Transcription: Code
[Every instance of
OutLoadingandLodingsetin the following is highlighted:]I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!