usePrevious

Holds the previous value of a box or getter.

Demo

Previous: undefined

Usage

	<script lang="ts">
  import { usePrevious } from "runed";
 
  let count = $state(0);
  const previous = usePrevious(() => count);
</script>
 
<button onclick={() => count++}>Count: {count}</button>
 
<pre>Previous: {`${previous.value}`}</pre>	
MIT

© 2024 Svecosystem Team