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 46 comments AI Visibility Is the New SEO for Indie Makers User Avatar 18 comments What's the point of AI generated comments? User Avatar 14 comments Product-led Growth User Avatar 6 comments Why good products are often hard to understand at first glance User Avatar 4 comments Looking for a few engineers to help test a lightweight PR review tool User Avatar 3 comments