-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: With AbstractComponent done, we can finally write out the type for forwardRef. For docs, check here: https://reactjs.org/docs/forwarding-refs.html Notable limitations: The Component returned from forwardRef has no defaultProps. Since they are in an invariant position, you won't be able to assign them defaultProps later. This is fine for most use cases. If we do need to support defaultProps on forwardRef components, we would need a function like: ``` withDefaultProps<Config, DefaultProps, Instance>( x: React.AbstractComponent<Config, void, Instance>, defaultProps: DefaultProps, ): React.AbstractComponent<React.Config<Config, DefaultProps>, DefaultProps, Instance>; ``` If there is demand for it, I will look more into creating a library with flow types that accomplishes this. ---- Special thanks to Sam Goldman for all the reviewing and discussions it took to get this done! Fixes: #6103 Reviewed By: samwgoldman Differential Revision: D13270565 fbshipit-source-id: e99718a0ca5942eb825d13dbcd3acf3f38b2802f
- Loading branch information
1 parent
77f2c40
commit 9a3377a
Showing
11 changed files
with
697 additions
and
581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.