Coding With Rich Harris 10

0 min read


Hello guys… welcome back to our channel… kali ini kita akan mencoba membuat simple dari coding yang kita buat sebelumnya…

Store Simplified

App.svelte

<script>
	import { count } from "./store.js"
	import Button from "./Button.svelte"
	export let name;
    
	const increment = () => {
		$count +=1;
	};

</script>

<main>
	<h1>Hi {name}! {$count}</h1>
	<p>Visit the <a href="https://svelte.dev/tutorial">Svelte tutorial</a> to learn how to build Svelte apps.</p>
	<form>
		<input type="text" bind:value={name} />
	</form>
	<Button count={$count} handleClick={increment} />
	<!-- <Button count={0} /> -->
</main>

Nah pada code diatas kita sudah menghapus code subscribe dan unsubsribe menjadi $count.. dan hasilnya pun sama…

oke link github ada disini… cyaaaa…

Bima Sena

Leave a Reply

Your email address will not be published. Required fields are marked *