Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ Certain lifecycle methods can only be used during component initialisation. To f
<button onclick={handleClick}>click me</button>
```

### missing_context

```
Context was not set in a parent component
```

The [`createContext()`](svelte#createContext) utility returns a `[get, set]` pair of functions. `get` will throw an error if `set` was not used to set the context in a parent component.

### snippet_without_render_tag

```
Expand Down
15 changes: 15 additions & 0 deletions apps/svelte.dev/content/docs/svelte/98-reference/20-svelte.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
SvelteComponentTyped,
afterUpdate,
beforeUpdate,
createContext,
createEventDispatcher,
createRawSnippet,
flushSync,
Expand Down Expand Up @@ -221,6 +222,20 @@ function beforeUpdate(fn: () => void): void;



## createContext

Returns a `[get, set]` pair of functions for working with context in a type-safe way.

<div class="ts-block">

```dts
function createContext<T>(): [() => T, (context: T) => T];
```

</div>



## createEventDispatcher

<blockquote class="tag deprecated note">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ Certain lifecycle methods can only be used during component initialisation. To f
<button onclick={handleClick}>click me</button>
```

### missing_context

```
Context was not set in a parent component
```

The [`createContext()`](svelte#createContext) utility returns a `[get, set]` pair of functions. `get` will throw an error if `set` was not used to set the context in a parent component.

### snippet_without_render_tag

```
Expand Down