svelte-select
svelte-select copied to clipboard
How to override `handleClear()`? (Or alternative approach suggestion)
Hello! Apologies if this is a dumb question as I am still getting accustomed to svelte.
I would like to override handleClear()
to additionally prompt the user to confirm they really want to clear the item. If they confirm they do then I would like to call the original handleClear
function.
According to your documentation, we should be able to override the handleClear
method, however my attempts have been futile.
This is what I have tried:
function handleClear() {
console.log('clearing');
}
...
<Select {items} multiple {handleClear} />
But it doesn't appear to be overriding. I found this after some brief research
If you export a const, class or function, it is readonly from outside the component. Function expressions are valid props, however.
Since handleClear
is defined as a function
and not a function expression, I think that might preventing me from overriding it.
Is there a way to accomplish this or am I misunderstanding something?
Thanks for your library and work by the way!