1
2 Comments

The Most Common Mistakes When Using React

Discover common React mistakes that developers make when using hooks, managing state, and rendering components. Learn how to identify and fix these mistakes to improve your application's performance and maintainability.

submitted this link to Icon for group Developers
Developers
on April 12, 2023
  1. 1

    Good article. However you have broken the rule 'Incorrectly relying on the current state value for calculating the next state' inside 'Working with simple arrays'.

    You shouldn't have

    setItems([...items, item]);

    but instead

    setItems((items) => [...items, item]);

    1. 1

      In that specific case it's actually not necessary to use the updater function since React will correctly handle the update.

Trending on Indie Hackers
Getting my first 100 users with $0: what actually worked User Avatar 57 comments What's the point of AI generated comments? User Avatar 32 comments Why can't your target customers always find your product? - Experience sharing User Avatar 8 comments Why I’m building an AI marketplace instead of another SaaS User Avatar 5 comments How does everyone setup their local computers for dev work? User Avatar 4 comments The exact prompt that creates a clear, convincing sales deck User Avatar 3 comments