Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

hydrationboundary.md

274 lines3.9 KB

1---
2id: HydrationBoundary
3title: HydrationBoundary
4---
5​
6# Class: HydrationBoundary\<Props, Events, Slots\>
7​
8Base class for Svelte components with some minor dev-enhancements. Used when dev=true.
9​
10Can be used to create strongly typed Svelte components.
11​
12#### Example:
13​
14You have component library on npm called `component-library`, from which
15you export a component called `MyComponent`. For Svelte+TypeScript users,
16you want to provide typings. Therefore you create a `index.d.ts`:
17​
18```ts
19import { SvelteComponent } from 'svelte'
20export class MyComponent extends SvelteComponent<{ foo: string }> {}
21```
22​
23Typing this makes it possible for IDEs like VS Code with the Svelte extension
24to provide intellisense and to use the component like this in a Svelte file
25with TypeScript:
26​
27```svelte
28<script lang="ts">
29 import { MyComponent } from 'component-library'
30</script>
31​
32<MyComponent foo={'bar'} />
33```
34​
35## Extends
36​
37- `SvelteComponent_1`\<`Props`, `Events`\>
38​
39## Type Parameters
40​
41β€’ **Props** _extends_ `Record`\<`string`, `any`\> = `any`
42​
43β€’ **Events** _extends_ `Record`\<`string`, `any`\> = `any`
44​
45β€’ **Slots** _extends_ `Record`\<`string`, `any`\> = `any`
46​
47## Indexable
48​
49\[`prop`: `string`\]: `any`
50​
51## Constructors
52​
53### new HydrationBoundary()
54​
55```ts
56new HydrationBoundary<Props, Events, Slots>(options): HydrationBoundary<Props, Events, Slots>
57```
58​
59#### Parameters
60​
61β€’ **options**: `ComponentConstructorOptions`\<`Props`\>
62​
63#### Returns
64​
65[`HydrationBoundary`](hydrationboundary.md)\<`Props`, `Events`, `Slots`\>
66​
67#### Overrides
68​
69`SvelteComponent_1<Props, Events>.constructor`
70​
71#### Defined in
72​
73node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:144
74​
75## Properties
76​
77### $$
78​
79```ts
80$$: any
81```
82​
83### PRIVATE API
84​
85Do not use, may change at any time
86​
87#### Inherited from
88​
89`SvelteComponent_1.$$`
90​
91#### Defined in
92​
93node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:102
94​
95---
96​
97### $$events_def
98​
99```ts
100$$events_def: Events
101```
102​
103For type checking capabilities only.
104Does not exist at runtime.
105​
106### DO NOT USE!
107​
108#### Defined in
109​
110node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:158
111​
112---
113​
114### $$prop_def
115​
116```ts
117$$prop_def: Props
118```
119​
120For type checking capabilities only.
121Does not exist at runtime.
122​
123### DO NOT USE!
124​
125#### Defined in
126​
127node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:151
128​
129---
130​
131### $$set
132​
133```ts
134$$set: any
135```
136​
137### PRIVATE API
138​
139Do not use, may change at any time
140​
141#### Inherited from
142​
143`SvelteComponent_1.$$set`
144​
145#### Defined in
146​
147node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:109
148​
149---
150​
151### $$slot_def
152​
153```ts
154$$slot_def: Slots
155```
156​
157For type checking capabilities only.
158Does not exist at runtime.
159​
160### DO NOT USE!
161​
162#### Defined in
163​
164node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:165
165​
166## Methods
167​
168### $capture_state()
169​
170```ts
171$capture_state(): void
172```
173​
174#### Returns
175​
176`void`
177​
178#### Defined in
179​
180node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:167
181​
182---
183​
184### $destroy()
185​
186```ts
187$destroy(): void
188```
189​
190#### Returns
191​
192`void`
193​
194#### Inherited from
195​
196`SvelteComponent_1.$destroy`
197​
198#### Defined in
199​
200node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:111
201​
202---
203​
204### $inject_state()
205​
206```ts
207$inject_state(): void
208```
209​
210#### Returns
211​
212`void`
213​
214#### Defined in
215​
216node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:169
217​
218---
219​
220### $on()
221​
222```ts
223$on<K>(type, callback): () => void
224```
225​
226#### Type Parameters
227​
228β€’ **K** _extends_ `string`
229​
230#### Parameters
231​
232β€’ **type**: `K`
233​
234β€’ **callback**: `undefined` \| `null` \| (`e`) => `void`
235​
236#### Returns
237​
238`Function`
239​
240##### Returns
241​
242`void`
243​
244#### Inherited from
245​
246`SvelteComponent_1.$on`
247​
248#### Defined in
249​
250node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:113
251​
252---
253​
254### $set()
255​
256```ts
257$set(props): void
258```
259​
260#### Parameters
261​
262β€’ **props**: `Partial`\<`Props`\>
263​
264#### Returns
265​
266`void`
267​
268#### Inherited from
269​
270`SvelteComponent_1.$set`
271​
272#### Defined in
273​
274node_modules/.pnpm/svelte@4.2.18/node_modules/svelte/types/index.d.ts:115