Skip to content

Commit d66cb51

Browse files
committed
docs
1 parent 6a0e4a2 commit d66cb51

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

documentation/docs/06-runtime/04-imperative-component-api.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ Note that unlike calling `new App(...)` in Svelte 4, things like effects (includ
3333

3434
## `unmount`
3535

36-
Unmounts a component created with [`mount`](#mount) or [`hydrate`](#hydrate):
36+
Unmounts a component that was previously created with [`mount`](#mount) or [`hydrate`](#hydrate).
37+
38+
If `options.outro` is `true`, [transitions](transition) will play before the component is removed from the DOM:
3739

3840
```js
39-
// @errors: 1109
4041
import { mount, unmount } from 'svelte';
4142
import App from './App.svelte';
4243

43-
const app = mount(App, {...});
44+
const app = mount(App, { target: document.body });
4445

4546
// later
46-
unmount(app);
47+
unmount(app, { outro: true });
4748
```
4849

4950
## `render`

packages/svelte/src/internal/client/render.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,18 @@ let mounted_components = new WeakMap();
271271

272272
/**
273273
* Unmounts a component that was previously mounted using `mount` or `hydrate`.
274+
*
275+
* If `options.outro` is `true`, [transitions](https://svelte.dev/docs/svelte/transition) will play before the component is removed from the DOM.
276+
*
277+
* ```js
278+
* import { mount, unmount } from 'svelte';
279+
* import App from './App.svelte';
280+
*
281+
* const app = mount(App, { target: document.body });
282+
*
283+
* // later...
284+
* unmount(app, { outro: true });
285+
* ```
274286
* @param {Record<string, any>} component
275287
* @param {{ outro?: boolean }} [options]
276288
*/

packages/svelte/types/index.d.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@ declare module 'svelte' {
448448
}): Exports;
449449
/**
450450
* Unmounts a component that was previously mounted using `mount` or `hydrate`.
451+
*
452+
* If `options.outro` is `true`, [transitions](https://svelte.dev/docs/svelte/transition) will play before the component is removed from the DOM.
453+
*
454+
* ```js
455+
* import { mount, unmount } from 'svelte';
456+
* import App from './App.svelte';
457+
*
458+
* const app = mount(App, { target: document.body });
459+
*
460+
* // later...
461+
* unmount(app, { outro: true });
462+
* ```
451463
*
452464
*/
453465
export function unmount(component: Record<string, any>, options?: {

0 commit comments

Comments
 (0)