---
title: "Discussion on \"Updating objects in a State. How not to use spread operator.\" | Hashnode"
description: "Discussion on \"Updating objects in a State. How not to use spread operator.\". Using Immer package to simplify updating objects in state."
url: "https://hashnode.com/posts/updating-objects-in-a-state-how-not-to-use-spread-operator/64808d8a837566372d407d58"
---

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

Discussion

# [Updating objects in a State. How not to use spread operator.](https://gauravv.hashnode.dev/updating-objects-in-a-state-how-not-to-use-spread-operator?utm_source=hashnode&utm_medium=feed)

Using Immer package to simplify updating objects in state.

Jun 7, 2023 · 4 min read · gauravv.hashnode.dev  
Read the article

-   [#react-state](https://hashnode.com/tag/react-state)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#frontend-development](https://hashnode.com/tag/frontend-development)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#objects](https://hashnode.com/tag/objects)

## Written by

[GAURAV BURANDE](https://hashnode.com/@gauravvan)

@gauravvan · India

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

Web development

I am a web developer.

## Responses 1

Markdown supported · ⌘↵ to post

[GAURAV BURANDE](https://hashnode.com/@gauravvan)

[Jun 8, 2023](https://hashnode.com/posts/updating-objects-in-a-state-how-not-to-use-spread-operator/64808d8a837566372d407d58/comment/6481a448ad7b6e44730b7dfd)

A dumb way to copy an object is using the spread operator.

Instead use JSON.parse(JSON.stringify(object)) or JS has a new global function for cloning, checkout structuredClone() **[developer.mozilla.org/en-US/docs/Web/API/structur…](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone)**
