]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: correct file types
authorEduardo San Martin Morote <posva13@gmail.com>
Thu, 1 Apr 2021 14:33:36 +0000 (16:33 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Thu, 1 Apr 2021 14:33:36 +0000 (16:33 +0200)
docs/cookbook/composing-stores.md
docs/core-concepts/actions.md
docs/core-concepts/index.md
docs/core-concepts/state.md
docs/ssr/index.md
docs/ssr/nuxt.md

index 74248b8f5d89648d56353192d7fa6f0c1cc1ebde..204bc7ad40b49326c9e491288a3586fd7eb55dfa 100644 (file)
@@ -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'
index 6da871aae126e05cd16b16ef5cc20d794b201929..20915e670f1fa6a3f3f3ba57acbbfc0a535415a2 100644 (file)
@@ -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()
index 539b14dfa88a6e88c27542638258559ef79d2963..17b67b41c02ea035b5884d0bd4b0664c92bc2d6f 100644 (file)
@@ -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()
index 22d3227ce10ec6c1b5001022ed91042731a24dc4..98a805c52f9205e8588622ab20e63ffd01aac831 100644 (file)
@@ -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' }
 ```
index ecdecc4e901d088c62c9a124082524e8ef6befad..8016d3a69b25886b6bcb2bdbc70070e6f304a627 100644 (file)
@@ -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)
 
index 020bec42c0c4ab4f9815d4602410759df863e3ce..f48a3620d728ac46035309dab867689aab2190b9 100644 (file)
@@ -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": [
     // ...