I agree with you, I just think that empathy is also remembering that not everyone has the same knowledge as you, and im all ok with people posting quirks about languages and frameworks, but we should always bring attetion to pitfalls and drawbacks whenever possible, someone that is starting on React might see such a comment and when replicating it, having much more headache than otherwise. Sorry for been agressive, just be kind to other and explain the drawbacks when possible
agreed.
Thanks for your inputs and advices, I learnt a few new things too!
However, I think there are no major mistakes on my post right?
I mean in general the differences I mentioned are true and I also researched a few other React articles and the official documentation as well.
Lastly can i delete this thread, because imagine if a newcomer or beginner (my target audience) reads this and gets confused. (Btw I agree with what you said to the person who started the thread, he should not have commented something advanced on a beginner level tutorial)
thanks
Yes, mutating state both ways is risky, but since I throw away the updater in my example, that risk is exactly 0.0000.
Also, just because it's not documented, it is not necessarily an anti-pattern. There are a lot of nice patterns nowhere to be found in the react documentation. Yes, creating an unneeded function that will be immediately eaten by the garbage collector may not be the best idea, but the point of the example was to show the relation between both hooks in terms even a beginner should be able to understand and not to show a best practice and 3. No again; if you want to warn about problems, show the code that causes the problem inside the given scope. Don't blame me for bad code you've seen elsewhere.
You have still failed to show why they would have a headache. Also, I would trust even beginners to be able to see that a useRef method is already available, so they wouldn't have to create their own and therefore recognize that this example was meant to illustrate the difference between useState and useRef and not more.
by headache i meant 1) it may be overwhelming to new learners. 2) I am sure I conveyed my point in the post while trying to stay as simple as possible and lastly neither is better, its just about usage
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I agree with you, I just think that empathy is also remembering that not everyone has the same knowledge as you, and im all ok with people posting quirks about languages and frameworks, but we should always bring attetion to pitfalls and drawbacks whenever possible, someone that is starting on React might see such a comment and when replicating it, having much more headache than otherwise. Sorry for been agressive, just be kind to other and explain the drawbacks when possible
agreed.
Thanks for your inputs and advices, I learnt a few new things too!
However, I think there are no major mistakes on my post right?
I mean in general the differences I mentioned are true and I also researched a few other React articles and the official documentation as well.
Lastly can i delete this thread, because imagine if a newcomer or beginner (my target audience) reads this and gets confused. (Btw I agree with what you said to the person who started the thread, he should not have commented something advanced on a beginner level tutorial)
thanks
Yes, mutating state both ways is risky, but since I throw away the updater in my example, that risk is exactly 0.0000.
Also, just because it's not documented, it is not necessarily an anti-pattern. There are a lot of nice patterns nowhere to be found in the react documentation. Yes, creating an unneeded function that will be immediately eaten by the garbage collector may not be the best idea, but the point of the example was to show the relation between both hooks in terms even a beginner should be able to understand and not to show a best practice and 3. No again; if you want to warn about problems, show the code that causes the problem inside the given scope. Don't blame me for bad code you've seen elsewhere.
You have still failed to show why they would have a headache. Also, I would trust even beginners to be able to see that a useRef method is already available, so they wouldn't have to create their own and therefore recognize that this example was meant to illustrate the difference between useState and useRef and not more.
by headache i meant 1) it may be overwhelming to new learners. 2) I am sure I conveyed my point in the post while trying to stay as simple as possible and lastly neither is better, its just about usage