---
title: "Discussion on \"Common Mistakes When Using React useState Hook (With Code Examples)\" | Hashnode"
description: "Discussion on \"Common Mistakes When Using React useState Hook (With Code Examples)\". Learn about the 6 most common mistakes developers make with React's useState hook, like forgetting to update state properly, and see clear examples..."
url: "https://hashnode.com/posts/common-mistakes-when-using-react-usestate-hook/658eee24b1d168f170e51c36"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Common Mistakes When Using React useState Hook (With Code Examples)](https://blog.akshaykaushik.eu.org/common-mistakes-when-using-react-usestate-hook?utm_source=hashnode&utm_medium=feed)

Learn about the 6 most common mistakes developers make with React's useState hook, like forgetting to update state properly, and see clear examples...

Dec 29, 2023 · 4 min read · blog.akshaykaushik.eu.org  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#hooks](https://hashnode.com/tag/hooks)
-   [#usestate](https://hashnode.com/tag/usestate)
-   [#software-engineering](https://hashnode.com/tag/software-engineering)

## Written by

[Akshay Kaushik](https://hashnode.com/@AkshayKaushik)

@AkshayKaushik

  
[View profile](https://hashnode.com/@AkshayKaushik)

Passionate web developer fueled by curiosity and driven to create exceptional user-centric solutions using Python, JavaScript, Django, Next

Hi, I'm Akshay Kaushik. Passionate web developer fueled by curiosity and driven to create exceptional user-centric solutions using Python, JavaScript, Django, Next.JS and cutting-edge technologies.

## Responses 2

Markdown supported · ⌘↵ to post

[Gabriele Petrioli](https://hashnode.com/@gpetrioli)

[Jan 10, 2024](https://hashnode.com/posts/common-mistakes-when-using-react-usestate-hook/658eee24b1d168f170e51c36/comment/659ebb02e6a9d0776c8dd5c1)

On your second point (2.Passing Functions Inline) using inline function or `useCallback` will not solve the issue if the handler is bound through a `useEffect`.

You should use the `onClick` of the element you want to bind. This way the inline would work directly. Also in your `useCallback` version, it would not work anyway since you give it an empty dependency array, which means it will still keep the stale `count` value for ever.

[Joe Shelby](https://hashnode.com/@JWSGeek)

[Jan 3, 2024](https://hashnode.com/posts/common-mistakes-when-using-react-usestate-hook/658eee24b1d168f170e51c36/comment/659599aafebf0930b10a1cf2)

One common mistake I've seen often with beginners is using parallel state and useEffect where a memo and callback would be better.

Suppose I have a state that's an object reflective of my API/domain, but I need to convert it into a different kind of complex object for a UI framework component that uses more generic, less domain-specific properties. (say, a dynamic form)

A common thing is to have a separate state for setter/getter and a useEffect that looks at the new form state and updates the old domain state, another looking for changes in the incoming props and recreating the new state. Aside from the risks of getting into a useEffect looping situation, it can lead to other errors if there's any way they get out of sync (often, due to trying to avoid the looping).

Instead of parallel state, have a useMemo take the domain state and turn it into the property value, and a callback that takes the updated property value from the contained component and setState it back. one version of the truth, so to speak.
