Should components manage their own state or be created when they need to be rendered?
kit-981 opened this issue · 0 comments
kit-981 commented
zi
looks great. I hope you don't mind questions :)
I was reading through the todo.rs example and it looks like the state of each item in the list is tracked in a TodoItem
struct that TodoMvc
holds. From what I can tell, a Todo
component for each TodoItem
is created each time TodoMvc
is rendered. Is there a reason that the state held by TodoItem
is not held by Todo
with TodoMvc
tracking a vector of components rather than a vector of TodoItem
structs?
I was thinking that creating Todo
components every time the TodoMvc
component is rendered would be expensive. I don't have much experience with similar frameworks (like yew
) so I'm not sure what the best or common practice is.