Merge pull request #2944 from sveltejs/component-binding-example

Fix component binding example
pull/2955/head
Jacob Wright 5 years ago committed by GitHub
commit 04162b9e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -593,12 +593,12 @@ You can bind to component props using the same mechanism.
Components also support `bind:this`, allowing you to interact with component instances programmatically.
> Note that we can do `{cart.empty}` rather than `{() => cart.empty()}`, since component methods are closures. You don't need to worry about the value of `this` when calling them.
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.
```html
<ShoppingCart bind:this={cart}/>
<button on:click={cart.empty}>
<button on:click={() => cart.empty()}>
Empty shopping cart
</button>
```
@ -1325,4 +1325,4 @@ It accepts a comma-separated list of variable names (not arbitrary expressions).
{@debug typeof user === 'object'}
```
The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.
The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.

Loading…
Cancel
Save