You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is often useful to maintain the state of a component when reparenting or changing the order of elements. Currently you cannot express the former and you express the latter by using keys. The use cases of reparenting are kind of an open question. Replacing key with constant identity stored in state could be an elegant and performant alternative solution for keys. The API would not be cumbersome with Hooks.
In the example below, foo and bar would be passed the same constant identity
let foo = (~contentId as id, children) = component(hooks => {
<view id />
});
let bar = (~contentId as id, children) = component(hooks => {
<view id />
});
let baz = () = component(hooks => {
let (id, hooks) = Hooks.componentId(hooks);
(hooks, Random.bool() ? <foo contentId=id /> : <bar contentId=id />)
});
An open question is what happens when you render two views with the same component identity at the same time (which is also problematic with keys but you expect keys to break in such cases)
The text was updated successfully, but these errors were encountered:
It is often useful to maintain the state of a component when reparenting or changing the order of elements. Currently you cannot express the former and you express the latter by using keys. The use cases of reparenting are kind of an open question. Replacing key with constant identity stored in state could be an elegant and performant alternative solution for keys. The API would not be cumbersome with Hooks.
In the example below,
foo
andbar
would be passed the same constant identityAn open question is what happens when you render two views with the same component identity at the same time (which is also problematic with keys but you expect keys to break in such cases)
The text was updated successfully, but these errors were encountered: