How to hide the modal component using svelte store?
Closed this issue · 1 comments
Gokulnath31 commented
There is an example showing how to open a modal using svelte-store. It would be better to have an example to hide using svelte-store
flekschas commented
Simply unset the store: modal.set(null);
.
<script>
import { writable } from 'svelte/store';
import Modal, { bind } from 'svelte-simple-modal';
import Popup from './Popup.svelte';
const modal = writable(null);
const showModal = () => modal.set(bind(Popup, { message: "It's a modal!" }));
const hideModal = () => modal.set(null);
</script>
<Modal show={$modal}>
<button on:click={showModal}>Show modal</button>
<button on:click={hideModal}>Hide modal</button>
</Modal>