Conditional re-rendering for Component embedded in Views #388
-
Hello! I'm currently working on implementing a circuit simulator with FuncUI, and I want to keep the app mostly in Elmish MVU structure since it's ported from a fable-elmish app. After trying to implement this re-rendering logic, and reading your helpful document and some discussion, I believe there are two common ways of handling that: 1 Component with key IdentityThis method fits well with my demand. However it can't watch the change of all state, but only one string value as the key. I did have a kind of solution that combine all state of this component into a str as key which force the component re-render when any of attribute of state change, and it doesn't look like a right and efficient solution.
2 Component using hook useStateThis also solved my problem, any updates to state will cause it to re-render by default, but it only takes in IWritable<'T> type, and I don't think I can create any of such type outside a Component, which force the whole app turn into Component and not what I want as elmish one.
I know this question can be kind of basic, but please let me know if there is other way of doing that, thank you! Here is my repo, https://github.com/KaiwenLiu1227/Issie-Avalonia-demo-app |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @KaiwenLiu1227 Nice to see that the https://github.com/tomcl/issie project is considering Avalonia!
Yes, currently view/component keys have to be strings - but there is no good reason for it actually. Changing the key from
You can actually just create a new instance of the let state: IWritable<int> = new State(42) |
Beta Was this translation helpful? Give feedback.
Hello @KaiwenLiu1227
Nice to see that the https://github.com/tomcl/issie project is considering Avalonia!
Yes, currently view/component keys have to be strings - but there is…