[Feature]: Provide a Default
trait implementation for the UseStateHandle
struct
#3597
Open
1 of 3 tasks
Labels
Problem:
While working on
yew-alert
, I noticed thatstd::default::Default
is not implemented foryew::UseStateHandle
. This could be beneficial when implementing theDefault
trait for a component'sProps
. For instance, in the case ofAlertProps
, it would resemble:This functionality is useful for allowing users to initialize the props struct by only passing some of the props values, with the others set to default, like so:
And then consume it in a component like so:
The same should apply to the
prop_or
attribute:Steps To Reproduce:
Attempt to implement
Default
for props containing aUseStateHandle
field type.Expected Behavior:
The
UseStateHandle
struct should have an implementation of theDefault
trait.Environment:
wasm32-unknown-unknown
Questionnaire:
Note
This feature is useful to adhere to the DRY principle and decouple logic from UI as shown in this example.
The text was updated successfully, but these errors were encountered: