-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Try using forwardRef #2222
base: main
Are you sure you want to change the base?
Try using forwardRef #2222
Conversation
johnrom
commented
Jan 17, 2020
•
edited
Loading
edited
This reverts commit 4ff1c5c.
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/jared/formik-docs/pfkqgq5m4 |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 31d669d:
|
Does this work with ts? |
yes, because but only because there is a cast. I left a comment on #2208 describing the pros and cons. as far as I can tell, it is the best we can do for now. |
I'm pretty scared of this since this cast effectively removes type safety for development. |
The type safety that is removed is specifically the safety between the two type definitions. If those type definitions go out of sync somehow, type safety will not be guaranteed. As long as those type definitions are in sync, type safety is guaranteed. It's definitely a trade-off, but is the only way to implement forwardRef that I can find. I'd recommend raising an issue on either typescript or react libraries. Coming from the owner of a large library, it might have some weight, and maybe one of the gurus would have a better solution. There's a lot of discussion here, but I don't see an issue opened specifically for the Alternatively, we could add a comment like |
Guys, if this is working, could you please write an example how to use it, as the docs don't seem clear about this? Thank you. |
@mlzsolti this PR is experimental. Since it uses type casting, it could introduce problems with future maintenance due to types becoming out of sync. It's a gamble I'm not sure Jared is willing to take. I would give 100% approval to this if we could ignore the specific rule this violates, since it will never be violated. |