From: Eduardo San Martin Morote Date: Thu, 1 Apr 2021 14:33:36 +0000 (+0200) Subject: docs: correct file types X-Git-Tag: v2.0.0-alpha.10~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dfb4bc4300dac4799737b9b58c87da6f17bc1e8d;p=thirdparty%2Fvuejs%2Fpinia.git docs: correct file types --- diff --git a/docs/cookbook/composing-stores.md b/docs/cookbook/composing-stores.md index 74248b8f..204bc7ad 100644 --- a/docs/cookbook/composing-stores.md +++ b/docs/cookbook/composing-stores.md @@ -8,7 +8,7 @@ Note that if one store uses an other store, **there is no need to create a new s You can call `useOtherStore()` at the top of any getter an action: -```ts +```js import { useUserStore } from './user' export const cartStore = defineStore({ @@ -37,7 +37,7 @@ export const cartStore = defineStore({ If you need to compute a value based on the `state` and/or `getters` of multiple stores, you may be able to import all the stores but one into the remaining store, but depending on how your stores are used across your application, **this would hurt your code splitting** because importing the store that imports all others stores, would result in **one single big chunk** with all of your stores. To prevent this, **we follow the rule above** and we create a new file with a new store: -```ts +```js import { defineStore } from 'pinia' import { useUserStore } from './user' import { useCartStore } from './cart' @@ -59,7 +59,7 @@ export const useSharedStore = defineStore({ When an actions needs to use multiple stores, we do the same, we create a new file with a new store: -```ts +```js import { defineStore } from 'pinia' import { useUserStore } from './user' import { useCartStore } from './cart' diff --git a/docs/core-concepts/actions.md b/docs/core-concepts/actions.md index 6da871aa..20915e67 100644 --- a/docs/core-concepts/actions.md +++ b/docs/core-concepts/actions.md @@ -20,7 +20,7 @@ Like [getters](./getters.md), actions get access to the _whole store instance_ t Actions are invoked like methods: -```ts +```js export default defineComponent({ setup() { const main = useMainStore() diff --git a/docs/core-concepts/index.md b/docs/core-concepts/index.md index 539b14df..17b67b41 100644 --- a/docs/core-concepts/index.md +++ b/docs/core-concepts/index.md @@ -8,7 +8,7 @@ import { defineStore } from 'pinia' // useStore could be anything like useUser, useCart export const useStore = defineStore({ // unique id of the store across your application - id: 'storeName' + id: 'storeName', }) ``` @@ -54,7 +54,7 @@ Once the store is instantiated, you can access any property defined in `state`, `store` in an object wrapped with `reactive`, meaning there is no need to write `.value` after getters but, like `props` in `setup`, we cannot destructure it: -```ts +```js export default defineComponent({ setup() { const store = useStore() diff --git a/docs/core-concepts/state.md b/docs/core-concepts/state.md index 22d3227c..98a805c5 100644 --- a/docs/core-concepts/state.md +++ b/docs/core-concepts/state.md @@ -33,7 +33,7 @@ store.counter++ or call the method `$patch` that allows you apply multiple changes at the same time with a partial `state` object: -```ts +```js store.$patch({ counter: store.counter + 1, name: 'Abalam', @@ -57,6 +57,6 @@ The main difference here is that `$patch()` allows you to group multiple changes You can replace the whole state of a store by setting its `$state` property to a new object: -```ts +```js store.$state = { counter: 666, name: 'Paimon' } ``` diff --git a/docs/ssr/index.md b/docs/ssr/index.md index ecdecc4e..8016d3a6 100644 --- a/docs/ssr/index.md +++ b/docs/ssr/index.md @@ -6,7 +6,7 @@ If you are using **Nuxt.js,** you need to read [**these instructions**](./nuxt.m Creating stores with Pinia should work out of the box for SSR as long as you call your `useStore()` functions at the top of `setup` functions, `getters` and `actions`: -```ts +```js export default defineComponent({ setup() { // this works because pinia knows what application is running inside of @@ -21,7 +21,7 @@ export default defineComponent({ If you need to use the store somewhere else, you need to pass the `pinia` instance [that was passed to the app](#install-the-plugin) to the `useStore()` function call: -```ts +```js const pinia = createPinia() const app = createApp(App) diff --git a/docs/ssr/nuxt.md b/docs/ssr/nuxt.md index 020bec42..f48a3620 100644 --- a/docs/ssr/nuxt.md +++ b/docs/ssr/nuxt.md @@ -74,7 +74,7 @@ export default { If you are using TypeScript or have a `jsconfig.json`, you should also add the types for `context.pinia`: -```js +```json { "types": [ // ...