Skip to content

Commit

Permalink
Update components docs for v0.9 (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
brynnjmccormick authored Oct 11, 2023
1 parent 1acd2c3 commit c35ee1b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions docs/next/basics/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
Any serious UI framework needs a way to compose and abstract UI elements. In Sycamore, this can be
accomplished using components.

Components in `sycamore` are simply functions slapped with the `#[component]` attribute that take an
argument of type `Scope` (a reactive scope). Component functions only run once (unlike React where
Components in `sycamore` are simply functions slapped with the `#[component]` attribute. Component functions only run once (unlike React where
functional-components are called on every render). Think of it as a builder-pattern for constructing
UI.

Expand Down Expand Up @@ -55,8 +54,8 @@ view! {

Accepting data from the parent sure is nice but it would be even better if updating the data in the
parent also updates the view in the child component! For components to automatically react to prop
changes, they should accept a signal. Most of the times, you'll want a `&ReadSignal` unless you want
mutable access to the data in which case you should use a `&Signal`. This way, updating the signal
changes, they should accept a signal. Most of the times, you'll want a `ReadSignal` unless you want
mutable access to the data in which case you should use a `Signal`. This way, updating the signal
will automatically update whatever is listening to it, even if it is inside the child component.

Here is an example of a simple component that displays the value of its prop and that automatically
Expand Down Expand Up @@ -84,8 +83,6 @@ view! {
state.set(1); // automatically updates value in MyComponent
```

Note how the `'a` lifetime is used to ensure that the data lives as long as the `Scope`.

## Component children

Components can also be wrappers around other child views by adding the `children` field to our
Expand Down

0 comments on commit c35ee1b

Please sign in to comment.