---
title: "Discussion on \"Common Error: Accidentally Mutating State in React\" | Hashnode"
description: "Discussion on \"Common Error: Accidentally Mutating State in React\". In React, the state is immutable. In simple terms it means that you should not modify it directly. Instead a new object should be created to set the state using setState.\nHere are two examples.\nModifying the state directly - Not Acceptable\nonChange(e..."
url: "https://hashnode.com/posts/common-error-accidentally-mutating-state-in-react/60c4a7a5a25fa357af841064"
---

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

Discussion

# [Common Error: Accidentally Mutating State in React](https://il3ven.hashnode.dev/common-error-accidentally-mutating-state-in-react?utm_source=hashnode&utm_medium=feed)

In React, the state is immutable. In simple terms it means that you should not modify it directly. Instead a new object should be created to set the state using setState. Here are two examples. Modifying the state directly - Not Acceptable onChange(e...

Jun 12, 2021 · 2 min read · il3ven.hashnode.dev  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#javascript](https://hashnode.com/tag/javascript)
-   [#functional-programming](https://hashnode.com/tag/functional-programming)
-   [#immutable](https://hashnode.com/tag/immutable)
-   [#best-practices](https://hashnode.com/tag/best-practices)

## Written by

[Vaibhav](https://hashnode.com/@il3ven)

@il3ven

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

Programmer

I explore the world of technology and share my findings here. Find me at https://twitter.com/il3ven

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
