prop
Overview
prop
gives access to props given to the views, so that they
can be used as data in the view, and to compose
paths for accessing state. prop
can also be
used in producers, in which case they pass the prop
s
received by the corresponding view.
Example
For example, if a TodoItem
component accepts a single prop id: string
, and
global state looks like:
{
todosById: {
todo1: {
title: "My first todo";
}
}
}
It is possible to access title
for the Todo with a given id
, by using
prop.id
as path. e.g
const TodoItem: view = ({
id, // shortcut for prop.id
title = observe.todosById[prop.id]
}) => { ... }
In this example, when TodoItem
is used as <TodoItem id="todo1" />
anywhere
in the application, it will get My first todo
as value of title
.