Replies: 2 comments 7 replies
-
Your two examples aren't the same thing. In the first, |
Beta Was this translation helpful? Give feedback.
-
Hooks are a natural progression React - we want people familiar with React to save their knowledge. It's also useful for chaining result into eachother and writing new hooks without the NewType pattern. It does have its downsides - IE there's no typesafe way of writing components that use hooks. Particular for the example you posted, there's no way of setting an initial value that depends on another value. |
Beta Was this translation helpful? Give feedback.
-
Taking a quick look, I see that this library uses hooks:
However this is Rust, and we have static typing and traits. A common way to solve a similar problem (e.g. in the various ECS libs) is to simply use arguments, for example for Bevy:
Wouldn't it be possible to do this for dioxus, like so:
Apologies if this has been discussed, or if you get a lot of critics targeted at hooks already (I know they are a polarizing issue). I thought it was worth discussing.
Beta Was this translation helpful? Give feedback.
All reactions