본문으로 건너뛰기

useRef

useRef<T>(defaultValue: T): Ref<T>

Parameters

defaultValue

T

Description

Instead of bind:this, you can bind this via the use: directive.

See
Example
<script>
import { onMount } from "svelte";
import { useRef } from "@cfcs/svelte";

const elementRef = useRef();

onMount(() => {
console.log(elementRef.current);
});
</script>
<div use:elementRef>Element</div>