Simplifying the if-block example

pull/9211/head
Ahmad Moghazi 3 years ago committed by GitHub
parent b62fc8c8fd
commit 7444706a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,15 +1,7 @@
<script>
let user = { loggedIn: false };
function toggle() {
user.loggedIn = !user.loggedIn;
}
let user = { loggedIn: false };
</script>
{#if user.loggedIn}
<button on:click={toggle}> Log out </button>
{/if}
{#if !user.loggedIn}
<button on:click={toggle}> Log in </button>
{/if}
<button on:click={() => user.loggedIn = !user.loggedIn}>
{user.loggedIn ? "Log out" : "Log in"}
</button>

Loading…
Cancel
Save