Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 1774

Tilia is born... still early version, ideas welcome :-)

$
0
0

Hi Czabaj,

Thanks for your interest !!

You should always track the whole tree, like this:

let tree = Tilia.use(tree)

Or if you receive a prop inside a component:

let branch = Tilia.use(branch)

This is because you always only track the exact keys you get from objects.

For example, if you use do

let tree = Tilia.use(tree)
Js.log(tree.foo.bar)

You are observing key “foo” in tree and key “bar” in foo.

This means that if someone changes tree.foo.banana, you are not notified because you never read the exact changed key “banana”.

But if someone replaces tree.foo, you are notified.

The only place where it is safe to not watch the whole tree is in child components receiving the branch from the parent because the parent will re-render if the whole branch is replaced and you will not have stale state.

I hope this clarifies it a little :blush:


Viewing all articles
Browse latest Browse all 1774

Trending Articles