aboutsummaryrefslogtreecommitdiff
path: root/examples/02-interactivity/README.md
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-01-30 20:19:24 +0000
committerHayleigh Thompson <me@hayleigh.dev>2024-01-30 20:19:24 +0000
commit98ed6018a4fd16f6e3bfb95a94a2ee82af861f6c (patch)
tree7d9efc7b2a1cd4dd1ed954b294362d003b198dbf /examples/02-interactivity/README.md
parentf60e4d653969036cb1950e55edd5099cc651cde5 (diff)
downloadlustre-98ed6018a4fd16f6e3bfb95a94a2ee82af861f6c.tar.gz
lustre-98ed6018a4fd16f6e3bfb95a94a2ee82af861f6c.zip
:art: Add padding for slim viewports.
Diffstat (limited to 'examples/02-interactivity/README.md')
-rw-r--r--examples/02-interactivity/README.md14
1 files changed, 13 insertions, 1 deletions
diff --git a/examples/02-interactivity/README.md b/examples/02-interactivity/README.md
index d97f618..d2e486a 100644
--- a/examples/02-interactivity/README.md
+++ b/examples/02-interactivity/README.md
@@ -94,7 +94,9 @@ _exhaustiveness checking_ to ensure we handle all possible messages.
### View
-
+Because state management is handled in our `update` function, our `view` becomes
+a simple function that takes a model and returns some HTML in the form of a
+Lustre `Element`.
```gleam
fn view(model: Model) -> Element(Msg) {
@@ -102,6 +104,16 @@ fn view(model: Model) -> Element(Msg) {
}
```
+In Lustre we call _all_ functions that return an `Element` "view functions": there's
+nothing special about the `view` that takes your model.
+
+Folks coming from frameworks like React might notice the absence of components
+with local encapsulated state. Lustre _does_ have components like this, but unlike
+other frameworks these are a fairly advanced use of the library and are typically
+used for larger pieces of UI like an entire form or a table. We'll cover how
+components fit into Lustre in later examples, but for now resist the urge to think
+in terms of "components" and "state" and try to think of your UI as a composition
+of _view functions_.
## Creating a dynamic Lustre application