Why hooks?
#328
Replies: 2 comments 7 replies
|
Your two examples aren't the same thing. In the first, |
5 replies
|
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. |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
All reactions