Docs: Exporting function expression vs declaration

Current docs give the impression that functions can not be default values for props. Suggestion to make the distinction between expressions and declarations clearer.
pull/7738/head
trbrc 6 years ago committed by GitHub
parent 1b7818b554
commit 204137f9ca

@ -48,10 +48,13 @@ Svelte uses the `export` keyword to mark a variable declaration as a *property*
// are immediately available
console.log(foo, bar);
// function declarations cannot be set externally,
// but can be accessed from outside
export function instanceMethod() {
alert(foo);
// Function expressions can also be props
export let format = (number) => (number.toFixed(2));
// Function declarations are added as methods
// on the component, rather than props
export function greetMethod() {
alert(`I'm a <${this.constructor.name}>!`);
}
// you can also use export { ... as ... } to have

Loading…
Cancel
Save