Skip to content

Commit

Permalink
Improve example of returning array of nodes (#1109)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaceno authored Feb 23, 2023
1 parent 9ee6a50 commit 44aa0df
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/architecture/views.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Components are recommended to be named in `camelCase` using a noun that concisel

### Components Returning Multiple VNodes

Components are allowed to return an array of VNodes. However, to make use of such components you'll need to spread their result.
Components are allowed to return an array of VNodes. However, to make use of such components in a list of other siblings, you'll need to spread their result.

```js
// Component : () -> [...VNodes]
Expand All @@ -120,7 +120,10 @@ const finishingMoveOptions = () => [
h("button", { onclick: BefriendHim }, text("Friendship")),
]

const view = () => h("div", {}, finishingMoveOptions())
const view = () => h("div", {}, [
h("em", {}, text("Finish them:"),
...finishingMoveOptions(),
])
```
<!-- In the "Mortal Kombat" videogame series there are multiple ways to finish off your opponent. The opportunity to do so occurs at the end of a match once the match announcer exclaims "Finish Him!" -->
Expand Down

0 comments on commit 44aa0df

Please sign in to comment.