Yeah. This is why most UI libraries/frameworks will provide some form of widget/element primitive which breaks the rules that have to be followed by user components.
In react, this is the DOM. It doesn't follow the react update model and so as long as react ends up patching the DOM it can preserve stuff like user selection, animation states and so on.
Even in Elm-ish "everything has to be pure" libraries you still end up with escape hatches. In Iced, for instance, you can either implement your own elements which can store state or turn a sub-app (Model + View & Update functions) into a stateful element.
But that's fine. These declarative/immediate paradigms are great at describing high level UI. Low level widget stuff can be done differently.
View all comments
Show parent comment
2
u/Dminik Sep 28 '26
Yeah. This is why most UI libraries/frameworks will provide some form of widget/element primitive which breaks the rules that have to be followed by user components.
In react, this is the DOM. It doesn't follow the react update model and so as long as react ends up patching the DOM it can preserve stuff like user selection, animation states and so on.
Even in Elm-ish "everything has to be pure" libraries you still end up with escape hatches. In Iced, for instance, you can either implement your own elements which can store state or turn a sub-app (Model + View & Update functions) into a stateful element.
But that's fine. These declarative/immediate paradigms are great at describing high level UI. Low level widget stuff can be done differently.