Skip to content
Advertisement

Tag: svelte

Having trouble displaying object property

I’m building a small pokedex using PokeAPI. I’m retrieving data from an endpoint and building my own object. The function that I’ve built for the latter runs on page load as follows: I’m able to console log the object and traverse it in devtools, and also able to JSON stringify it and display within html. But whenever I try to

Capture value from an input with svelte

I’m trying to capture the value of an input using the svelte framework When initializing the local environment I already get the following error in the console: Uncaught TypeError: Cannot read properties of null (reading ‘value’) Visual Studio Code marks the code snippet .value when I try to capture the input value with the error: Property ‘value’ does not exist

Calling array object in src does not work

I have an array : I am looping in it: This here does not work: src={icon} Correct way should be like this: If I replace the {icon} with string it works! Can someone tell me why? Thank you Answer The reason this doesn’t work is because <Icon src=”xxx” /> does not expect a string but an object. If you import

Open one accordion section at a time. (Svelte)

I’d like to ask someone who can figure out how to allow this accordion component to open only one section at a time. It means that if a new accordion is open the previous one has to close automatically. In the ideal situation, this function could be optional for specific accordions. Thank you for your time. Accordion.svelte app.svelte Answer For

Hover on object entries triggers unnecessary reactivity in Svelte

I have an object that I loop over with an each block. When I hover, I temporarily change a property on the actual object entry and use it to assign a class. This works fine, but it also causes other reactivity to be triggered unnecessarily often. REPL: https://svelte.dev/repl/c658cccd0bc2471a8f9c4758387340c5?version=3.48.0 n the console, you can see how often the reactivity on the

Advertisement