diff --git a/website/documents/definition.js b/website/documents/definition.js deleted file mode 100644 index e69de29b..00000000 diff --git a/website/documents/guides/04-handling-events.md b/website/documents/guides/04-handling-events.md index 2d9f4bdb..4dbf3c4c 100644 --- a/website/documents/guides/04-handling-events.md +++ b/website/documents/guides/04-handling-events.md @@ -7,7 +7,7 @@ Most web applications require some measure of interactivity, where the user inte ## DOM Event Props You can attach event callbacks to host element directly using event props. These props start with `on`, are all lowercase, and correspond to the event type (`onclick`, `onkeydown`). By combining event props, local variables and `this.refresh()`, you can write interactive components. -```jsx +```jsx live import {renderer} from "@b9g/crank/dom"; function *Counter() { let count = 0; diff --git a/website/documents/index.md b/website/documents/index.md index 4da41554..f2d1b4d0 100644 --- a/website/documents/index.md +++ b/website/documents/index.md @@ -272,6 +272,12 @@ async function Definition({word}) { // API courtesy https://dictionaryapi.dev const res = await fetch(`https://api.dictionaryapi.dev/api/v2/entries/en/${word}`); const data = await res.json(); + if (!Array.isArray(data)) { + return ( +
No definition found for {word}
+ ); + } + const {phonetic, meanings} = data[0]; const {partOfSpeech, definitions} = meanings[0]; const {definition} = definitions[0]; @@ -298,12 +304,17 @@ function *Dictionary() { for ({} of this) { yield ( <> -
+
{" "}
-
+