Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

This `dispatch()` is completely ignored. Why?

$
0
0

I created a reproduction for an issue with Svelte dispatch not being called:

Steps to reproduce

  1. Open the reproduction

  2. Open the browser console

  3. Go on the "About" page using the link

  4. I sould see the message: "handleInput" but I'm not

Relevant code

<script>    import Select from 'svelte-select';    import { createEventDispatcher } from 'svelte';    export let value = undefined;    export let id = undefined;    const dispatch = createEventDispatcher();    let result;    let items = [        { value: 'one', label: 'One' },        { value: 'two', label: 'Two' },        { value: 'three', label: 'Three' },    ];    $: if (id !== undefined) {        result = id;    }    $: if (result != undefined) {        value = { value: 'custom', label: 'Custom' };        console.log("this should dispatch!")        dispatch('input', value);        console.log("is it dispatched?")    }</script><Select {value} {items} on:change on:input />

The dispatch('input', value) is completely ignored.

Why?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>