From f65379f38b0276fc8d7faae753018042e6ed01bf Mon Sep 17 00:00:00 2001 From: Jacob Wright Date: Mon, 3 Jun 2019 13:26:47 -0600 Subject: [PATCH] Fix component binding example While `cart.empty` could be passed around, it is undefined on first render and results in an error being thrown. The example here was broken and needed fixing. --- site/content/docs/02-template-syntax.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 167d1fa3a2..aad7e3fc19 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -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 - ``` @@ -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. \ No newline at end of file +The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.