File tree Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ <script >
2
+ </script >
Original file line number Diff line number Diff line change
1
+ import type { PageLoad } from "./$types"
2
+
3
+ export const load = ( async ( { params } ) => {
4
+ return {
5
+ title : "useRef" ,
6
+ react : ( await import ( "./react.jsx?raw" ) ) . default ,
7
+ svelte : ( await import ( "./svelte.svelte?raw" ) ) . default ,
8
+ }
9
+ } ) satisfies PageLoad
Original file line number Diff line number Diff line change
1
+ import React , { useRef } from 'react'
2
+
3
+ export default function TextInputWithFocusButton ( ) {
4
+ const inputEl = useRef ( null )
5
+ const handleClick = ( ) => {
6
+ inputEl . current . focus ( )
7
+ }
8
+
9
+ return (
10
+ < >
11
+ < input ref = { inputEl } />
12
+ < button onClick = { handleClick } > Focus the input</ button >
13
+ </ >
14
+ )
15
+ }
Original file line number Diff line number Diff line change
1
+ <script >
2
+ let inputEl
3
+
4
+ function handleClick () {
5
+ inputEl .focus ()
6
+ }
7
+ </script >
8
+
9
+ <input bind:this ={inputEl } />
10
+ <button on:click ={handleClick }>Focus the input</button >
Original file line number Diff line number Diff line change 10
10
let tile1Url = " /useState"
11
11
let tile2Url = " /useEffect"
12
12
let tile3Url = " /useMemo"
13
+ let tile4Url = " /useRef"
13
14
</script >
14
15
15
16
<!-- App Shell -->
70
71
href ={tile3Url }
71
72
class ={tile3Url === $page .url .pathname ? " bg-primary-500" : " " }><Icon icon =" code" /></AppRailTile
72
73
>
74
+ <AppRailTile
75
+ label =" useRef"
76
+ title =" useRef"
77
+ value ={4 }
78
+ tag =" a"
79
+ href ={tile4Url }
80
+ class ={tile4Url === $page .url .pathname ? " bg-primary-500" : " " }><Icon icon =" code" /></AppRailTile
81
+ >
73
82
</svelte:fragment >
74
83
75
84
<svelte:fragment slot =" trail" >
You can’t perform that action at this time.
0 commit comments