-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest fix for useRef-types in hooks #3222
Conversation
What is the rationale for these changes? Is there a related issue? |
This originated from slack. The issue is that This is because components expect declare function useRef<T>(): Ref<T | undefined>; The quickest fix for this would be to just switch the But lets make this an opportunity to fix the whole preact Ref typing situation. As developit said it on slack, there are currently 4 or 6 different Ref types spread over The ideal situation would be to have just one set in stone type Ref<T> = {current: T}; And since it's implemented in core, put it into No special Refs with Also, although |
@tomasklaen these are similar types to other frameworks implementing these paradigms (can be seen in React as well) I would stick to the deterministic nature of |
I see that this is pretty much 1:1 copy of how react defines their types, and compatibility with react is definitely a good thing. I've also realized you can make non initialized refs mutable by adding But if we care about compatibilty with react, the interfaces should be Oh and what about consolidating all refs from both preact's main definition file and hooks definitions into these 2, defined in core, and imported into hooks? Or do we not care that core has its own different Ref interfaces? |
No description provided.