MolakDul
MolakDul
NNuxt
Created by MolakDul on 7/30/2024 in #❓・help
Pinia and Nuxt Layouts
Hey! Quick question about Pinia. I have a very simple user store with a state and a "fetch" action that populates this state via a GQL request. I trigger this fetch in the top-level component app.vue:
const userStore = useUserStore();
userStore.fetch();
const userStore = useUserStore();
userStore.fetch();
But when I want to access the state in my default layout to display the user's photo like this:
const userStore = useUserStore();
console.log(userStore.photo);
const userStore = useUserStore();
console.log(userStore.photo);
Well, the console.log is empty... Yet everything is well initialized if I inspect with NuxtDevTools. What is the issue with layouts ? Because i'm using the state of this very same store in a page and display them without any issue ... Any idea?
4 replies
NNuxt
Created by MolakDul on 6/27/2024 in #❓・help
Directive v-debounce
Hello! I have been trying for a while to create a custom directive debounce.ts in Nuxt without success. The idea is to have an input like this:
<input
v-model="model"
v-debounce="500"
@input="$emit('fieldUpdated')"
/>
<input
v-model="model"
v-debounce="500"
@input="$emit('fieldUpdated')"
/>
And have my variable "model" updated only after 500ms. Have you ever done something like this? PS: I know there are "easy" ways to do this, especially with lodash, but I don't want to add such a large library just for that.
5 replies
NNuxt
Created by MolakDul on 6/6/2024 in #❓・help
Nuxt Storybook
I tried to install Storybook on a fresh Nuxt 3 project with just some linter and tailwind installed but after running the two following commands: npx nuxi@latest module add storybook npx storybook-nuxt init i get this error: $ nuxt prepare ℹ Using Tailwind CSS from ~/assets/css/tailwind.css nuxt:tailwindcss 5:53:04 PM ERROR Cannot read properties of undefined (reading 'STORYBOOK') 5:53:04 PM at setup (node_modules/@nuxtjs/storybook/dist/module.mjs:122:25) at normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:2112:37) at async installModule (node_modules/@nuxt/kit/dist/index.mjs:2415:95) at async initNuxt (node_modules/nuxt/dist/index.mjs:4233:7) at async loadNuxt (node_modules/nuxt/dist/index.mjs:4331:5) at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2570:19) at async Object.run (node_modules/nuxi/dist/chunks/prepare.mjs:53:18) at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1648:16) at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1639:11) at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1777:7) ERROR Cannot read properties of undefined (reading 'STORYBOOK') 5:53:04 PM error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. ❌ Package installation failed with code 1 Any idea how i can fix this issue ?
4 replies