File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,19 @@ use std::rc::Rc;
3131///
3232/// Additionally, a [`Component`] is capable of producing a `Message` to notify
3333/// the parent application of any relevant interactions.
34+ ///
35+ /// # State
36+ /// A component can store its state in one of two ways: either as data within the
37+ /// implementor of the trait, or in a type [`State`][Component::State] that is managed
38+ /// by the runtime and provided to the trait methods. These two approaches are not
39+ /// mutually exclusive and have opposite pros and cons.
40+ ///
41+ /// For instance, if a piece of state is needed by multiple components that reside
42+ /// in different branches of the tree, then it's more convenient to let a common
43+ /// ancestor store it and pass it down.
44+ ///
45+ /// On the other hand, if a piece of state is only needed by the component itself,
46+ /// you can store it as part of its internal [`State`][Component::State].
3447#[ cfg( feature = "lazy" ) ]
3548#[ deprecated(
3649 since = "0.13.0" ,
You can’t perform that action at this time.
0 commit comments