2021-03-04
2274
#react
Sonny Recio
35517
Mar 4, 2021 â‹… 8 min read

The noob’s guide to useState

Sonny Recio 10% Entrepreneur | Fitness Junkie | Software Engineer | Fullstack web developer | Game Developer | Article writer and musician | Lifelong learner

Recent posts:

Understanding Security In React Native Applications

Understanding security in React Native applications

Explore the various security threats facing React Native mobile applications and how to mitigate them.

Wisdom Ekpotu
Mar 27, 2024 â‹… 10 min read
Warp Adoption Guide: Overview, Examples, And Alternatives

warp adoption guide: Overview, examples, and alternatives

The warp web framework for Rust offers many enticing features. Let’s see when and why you should consider using warp in your projects.

Ukeje Goodness
Mar 26, 2024 â‹… 8 min read
Integrating Next Js And Signalr For Enhanced Real Time Web App Capabilities

Integrating Next.js and SignalR to build real-time web apps

In this tutorial, you’ll learn how to integrate Next.js and SignalR to build an enhanced real-time web application.

Clara Ekekenta
Mar 25, 2024 â‹… 8 min read
Exploring Tailwind Oxide

Exploring Tailwind Oxide

Tailwind Oxide was introduced to address common issues that exist with Tailwind CSS, such as the complex setup process.

Marie Starck
Mar 22, 2024 â‹… 5 min read
View all posts

10 Replies to "The noob’s guide to <code>useState</code>"

  1. Honestly, most of this article is pretty useless. Anyone who has read the “getting started” of hooks won’t do any of this. Only the part about not passing setValue to the children might be a real world case.

    It’s a bit preposterous to say that I’m using it wrong and then make a list of super obvious mistakes that honestly, the incredible minority of newbies would do.

    Clickbait article, wasted my time.

  2. Title should be “I was using use state wrong”
    It would be very hard to make some of those mistakes if you read the React documentation.

  3. Been working with hooks since they were released, reviewed thousands of PRs.
    Never saw even one of this cases.

  4. Not even that was realistic, why would someone use a prop to pass a function that can be easily imported.

  5. Yeah this article is pointless and clickbaity. I was like “oh what am I doing wrong?” and I thought it would be a best practice thing like don’t use too many useStates or use somethinge else. Then it was just like “don’t change the state directly” which is the first thing you learn.

  6. The first example isn’t really valid is it? You can’t reassign a constant, and that’s the point of declaring it that way.

  7. The point displayed by example in the section “Not putting useState at the top of component body or functions” is wrong.
    By top level the React documentation does not mean the line number but the nesting of hooks inside other elements. Both given examples are completely valid.
    As long as your hook is on top level you can put in any working location of your component.

Leave a Reply