Skip to content

Commit

Permalink
docs: minor corrections (#2879)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewvasilchuk authored Jan 6, 2025
1 parent 2a9fd92 commit c82e089
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/docs/cookbook/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Here are some examples of composables that cannot be used in an option stores (b
On the other hand, when defining a setup store, you can use almost any composable since every property gets discerned into state, action, or getter:

```ts
import { defineStore, skipHydrate } from 'pinia'
import { defineStore } from 'pinia'
import { useMediaControls } from '@vueuse/core'

export const useVideoPlayer = defineStore('video', () => {
Expand Down Expand Up @@ -78,7 +78,7 @@ When dealing with [Server Side Rendering](../ssr/index.md), you need to take car
In [Option Stores](#option-stores), you need to define a `hydrate()` function. This function is called when the store is instantiated on the client (the browser) when there is an initial state available at the time the store is created. The reason we need to define this function is because in such scenario, `state()` is not called.

```ts
import { defineStore, skipHydrate } from 'pinia'
import { defineStore } from 'pinia'
import { useLocalStorage } from '@vueuse/core'

export const useAuthStore = defineStore('auth', {
Expand Down
10 changes: 7 additions & 3 deletions packages/docs/cookbook/composing-stores.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Note that if one store uses another store, you can directly import and call the
When it comes to _setup stores_, you can simply use one of the stores **at the top** of the store function:

```ts
import { defineStore } from 'pinia'
import { useUserStore } from './user'
import { apiPurchase } from './api'

export const useCartStore = defineStore('cart', () => {
const user = useUserStore()
Expand All @@ -58,7 +60,7 @@ export const useCartStore = defineStore('cart', () => {
})

function purchase() {
return apiPurchase(user.id, this.list)
return apiPurchase(user.id, list.value)
}

return { summary, purchase }
Expand Down Expand Up @@ -91,7 +93,8 @@ The same applies to _actions_:
```js
import { defineStore } from 'pinia'
import { useUserStore } from './user'

import { apiOrderCart } from './api'

export const useCartStore = defineStore('cart', {
actions: {
async orderCart() {
Expand All @@ -114,7 +117,8 @@ Since actions can be asynchronous, make sure **all of your `useStore()` calls ap
```js{7-8,11-13}
import { defineStore } from 'pinia'
import { useUserStore } from './user'
import { apiOrderCart } from './api'
export const useCartStore = defineStore('cart', {
actions: {
async orderCart() {
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/cookbook/vscode-snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

These are some snippets that I use in VS Code to make my life easier.

Manage user snippets with <kbd>⇧</kbd> <kbd>⌘</kbd> <kbd>P</kbd> / <kbd>⇧</kbd> <kbd>⌃</kbd> <kbd>P</kbd> and then `Snippets: Configure User Snippets`.
Manage user snippets with <kbd>⇧ Shift</kbd>+<kbd>⌘ Command</kbd>+<kbd>P</kbd> / <kbd>⇧ Shift</kbd>+<kbd>⌃ Control</kbd>+<kbd>P</kbd> and then `Snippets: Configure User Snippets`.

```json
{
Expand Down

0 comments on commit c82e089

Please sign in to comment.