Skip to content

Commit

Permalink
docs: Update example-setstate.mdx (#829)
Browse files Browse the repository at this point in the history
Fixed writing mistakes.
  • Loading branch information
SyedTayyabUlMazhar committed Jul 14, 2021
1 parent 16a3d0f commit bc890f7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions website/docs/example-setstate.mdx
Expand Up @@ -33,7 +33,7 @@ title: React & Immer

## useState + Immer

The `useState` hook assumes any state that is stored inside it is treated as immutable. Deep updates in the state of React components can be greatly simplified as by using Immer. To following example shows how to use `produce` in combination with `useState`, and can be tried on [CodeSandbox](https://codesandbox.io/s/immer-usestate-ujkgg?file=/src/index.js).
The `useState` hook assumes any state that is stored inside it is treated as immutable. Deep updates in the state of React components can be greatly simplified as by using Immer. The following example shows how to use `produce` in combination with `useState`, and can be tried on [CodeSandbox](https://codesandbox.io/s/immer-usestate-ujkgg?file=/src/index.js).

```javascript
import React, { useCallback, useState } from "react";
Expand Down Expand Up @@ -80,7 +80,7 @@ const TodoList = () => {

## useImmer

Since all state updaters follow the same pattern where the update function is wrapped in `produce`, it is also possible to simply the above by leveraging the [use-immer](https://www.npmjs.com/package/use-immer) package that will wrap updater functions in `produce` automatically:
Since all state updaters follow the same pattern where the update function is wrapped in `produce`, it is also possible to simplify the above by leveraging the [use-immer](https://www.npmjs.com/package/use-immer) package that will wrap updater functions in `produce` automatically:

```javascript
import React, { useCallback } from "react";
Expand Down

0 comments on commit bc890f7

Please sign in to comment.