Skip to content

Commit b835eae

Browse files
Use nanoid in docs (#539)
1 parent 43331c8 commit b835eae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/api/createAction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ By default, the generated action creators accept a single argument, which become
5454
In many cases, you may want to write additional logic to customize the creation of the `payload` value, such as accepting multiple parameters for the action creator, generating a random ID, or getting the current timestamp. To do this, `createAction` accepts an optional second argument: a "prepare callback" that will be used to construct the payload value.
5555
5656
```js
57-
import v4 from 'uuid/v4'
57+
import { nanoid } from '@reduxjs/toolkit'
5858

5959
const addTodo = createAction('todos/add', function prepare(text) {
6060
return {
6161
payload: {
6262
text,
63-
id: v4(),
63+
id: nanoid(),
6464
createdAt: new Date().toISOString()
6565
}
6666
}
@@ -72,7 +72,7 @@ console.log(addTodo('Write more docs'))
7272
* type: 'todos/add',
7373
* payload: {
7474
* text: 'Write more docs',
75-
* id: '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed',
75+
* id: '4AJvwMSWEHCchcWYga3dj',
7676
* createdAt: '2019-10-03T07:53:36.581Z'
7777
* }
7878
* }

0 commit comments

Comments
 (0)